472,789 Members | 1,034 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,789 software developers and data experts.

Easy (?) PHP/MySQL question

I have installed PHP and MySQL using WAMP5 as my server on a Vista
machine.

I can run PHP scripts no problem.

I can create and populate MySQL tables no problem.

I cannot seem to get my PHP script to recognize any MySQL commands.

The following code fails silently, i.e. even the "die" text won't
display.
//Database Connection
$msdb = mysql_connect("127.0.0.1", "", "") or die('Could not connect
to MySQL: ' . mysql_error());
mysql_select_db("test", $msdb) or die('Could not select the database:
' . mysql_error());

What piece of info am I missing here? Is there some perl-style
include that I'm missing? Or is it some configuration parameter? Any
help appreciated.
Sep 19 '08 #1
8 5059
Stevebo wrote:
I have installed PHP and MySQL using WAMP5 as my server on a Vista
machine.

I can run PHP scripts no problem.

I can create and populate MySQL tables no problem.

I cannot seem to get my PHP script to recognize any MySQL commands.

The following code fails silently, i.e. even the "die" text won't
display.
//Database Connection
$msdb = mysql_connect("127.0.0.1", "", "") or die('Could not connect
to MySQL: ' . mysql_error());
mysql_select_db("test", $msdb) or die('Could not select the database:
' . mysql_error());

What piece of info am I missing here? Is there some perl-style
include that I'm missing? Or is it some configuration parameter? Any
help appreciated.
Enable all error reporting and display the errors. In your php.ini
file, ensure you have:

display_errors=on
error_reporting=E_ALL

I suspect your mysql extension isn't getting loaded.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 19 '08 #2

"Stevebo" <fa********@gmail.comwrote in message
news:b2**********************************@79g2000h sk.googlegroups.com...
>I have installed PHP and MySQL using WAMP5 as my server on a Vista
machine.

I can run PHP scripts no problem.

I can create and populate MySQL tables no problem.

I cannot seem to get my PHP script to recognize any MySQL commands.

The following code fails silently, i.e. even the "die" text won't
display.
//Database Connection
$msdb = mysql_connect("127.0.0.1", "", "") or die('Could not connect
to MySQL: ' . mysql_error());
mysql_select_db("test", $msdb) or die('Could not select the
database:
' . mysql_error());

What piece of info am I missing here? Is there some perl-style
include that I'm missing? Or is it some configuration parameter?
Any
help appreciated.
Can you connect to mySQL using another client?
MySQL query browser.. mySQL admin?

Turning on the error reporting (as Jerry suggested) is of course good.
You can do that from the tray icon.
While you are there, check to see if the extension for mySQL is
loaded.
Can you connect to the DB if you select "phpMyAdmin" from the tray
menu?

Richard.
Sep 19 '08 #3
On Sep 19, 2:20*pm, "Richard" <root@localhostwrote:
Can you connect to mySQL using another client?
MySQL query browser.. mySQL admin?
Yes. i can do so with MySQL query browser
Turning on the error reporting (as Jerry suggested) is of course good.
I did this using the WAMP Tray Icon =Config Files, but nothing
changed
While you are there, check to see if the extension for mySQL is
loaded.
The extension = php_mysql.dll in php.ini is uncommented, but it isn't
loaded either, nor does it show up in phpinfo()
Can you connect to the DB if you select "phpMyAdmin" from the tray
menu?
No, because it's trying to use http://localhost/, which for some
reason maps to http://www.localhost.com/ and gives an error that the
connection was reset (essentially a 404). If I substitute http://127.0.0.1/,
my page gets served but no database response. When I go to
http://127.0.0.1/phpMyAdmin, I receive

"Cannot load mysql extension. Please check your PHP configuration. -
Documentation"

The hosts file has hundreds of entries for localhost, most of them put
in by Spybot. I tried to edit the hosts file, but it's read-only.
when I remove that, and forcibly try to overwrite it, I still can't.

Any ideas?
Sep 19 '08 #4
Testing. My last post disappeared.
Sep 19 '08 #5
Stevebo wrote:
On Sep 19, 2:20 pm, "Richard" <root@localhostwrote:
>Can you connect to mySQL using another client?
MySQL query browser.. mySQL admin?

Yes. i can do so with MySQL query browser
>Turning on the error reporting (as Jerry suggested) is of course good.

I did this using the WAMP Tray Icon =Config Files, but nothing
changed
>While you are there, check to see if the extension for mySQL is
loaded.

The extension = php_mysql.dll in php.ini is uncommented, but it isn't
loaded either, nor does it show up in phpinfo()
>Can you connect to the DB if you select "phpMyAdmin" from the tray
menu?

No, because it's trying to use http://localhost/, which for some
reason maps to http://www.localhost.com/ and gives an error that the
connection was reset (essentially a 404). If I substitute http://127.0.0.1/,
my page gets served but no database response. When I go to
http://127.0.0.1/phpMyAdmin, I receive

"Cannot load mysql extension. Please check your PHP configuration. -
Documentation"

The hosts file has hundreds of entries for localhost, most of them put
in by Spybot. I tried to edit the hosts file, but it's read-only.
when I remove that, and forcibly try to overwrite it, I still can't.

Any ideas?
Did you stop and restart your Apache server after making changes to the
php.ini? Are you changing the correct php.ini file (see phpinfo()).

And are the MySQL client libraries in a place where php can access them,
i.e. in a directory listed in your PATH environment variable?

I've never used xampp (I do manual installs), so I don't know how it's
set up. But once you have it set up, everything works well.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 19 '08 #6
r0g
Stevebo wrote:
On Sep 19, 2:20 pm, "Richard" <root@localhostwrote:
>Can you connect to mySQL using another client?
MySQL query browser.. mySQL admin?
<snip>
The hosts file has hundreds of entries for localhost, most of them put
in by Spybot. I tried to edit the hosts file, but it's read-only.
when I remove that, and forcibly try to overwrite it, I still can't.

Any ideas?
Oh that's not good. Windows can only handle a finite number of hosts
file entries without throwing a hissy fit, plus you have no ide what is
in there. I'd lose search and destroy, (right-click, security, advanced,
owner) and reclaim ownership of the file and delete everything in it
except "127.0.0.1 localhost"

If XAMPP still isn't happy after that then try WAMP instead, I always
found it was the better of the two :-)

Of course, as Jerry suggests you could try the manual install. While it
takes longer it _is_ educational :-)

Roger.
Sep 21 '08 #7
On Sep 19, 5:41*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
php.ini? *Are you changing the correct php.ini file (see phpinfo()).
Yes Jerry, that was it! The wrong php.ini file. Strange, you would
have thought WAMP would pick the correct path, but perhaps it got
confused with an earlier installation of PHP.

Also Roger, thanks for the advice regarding the hosts file, but no
matter what I do to the file, I can't seem to unlock it, so the
problem persists. Since Jerry's advice got me up and running for the
moment, I'll re-visit the localhost thing when I get a chance. I'm
mostly just trying to do local development, not necessarily run my own
public web server.

Thanks for all your patience with and advice about my questions.
Steve
Sep 21 '08 #8
Stevebo wrote:
The hosts file has hundreds of entries for localhost, most of them put
in by Spybot. I tried to edit the hosts file, but it's read-only.
when I remove that, and forcibly try to overwrite it, I still can't.

Any ideas?
That's a bad idea. The hosts file was never intended to do mass
redirections. The whole file gets parsed on every net access to see if
the domain should resolve to a specific address before a DNS lookup is
made. A long hosts file can *really* bog down your net connectivity.

If you can't change the hosts file you have most likely configured
Spybot to protect it from tampering. Switch the hosts file protection
off in Spybot, then you should be able to edit it just fine.

Bye!
Sep 22 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: MJL | last post by:
This is a mysql/php question (but a little more on the mysql side.) The two are so closely related these days, I thought it would be ok to ask here. I installed on my Suse Linux system mysql 4.0...
2
by: pieter_hordijk | last post by:
Hi all, maybe this isn't a php question, but a MySQL question. If so I'm sorry for asking you guys to help me :) I know this question is asked often in NGs, but I couldn't find the answer...
0
by: | last post by:
I don't know SQL at all, but I have a problem now because I must use SQL in my PHP scripts. So please help me! I have 2 tables: id | name ----------- 1 | thing1 2 | thing2 3 | thing3 4 ...
3
by: John Smith | last post by:
Hi I am currently reviewing our backup procedures. Part of the issue has been finding the right fit. There are obviously backup products that provide mysql agents but unfortunately can not for...
2
by: kimshapiro100 | last post by:
Question on PhP, MySQL I am thinking of a consumer internet business for which I will have to have a database driven site built. I am thinking of using PhP, MySQL as the main technologies...
1
by: Jim Carlock | last post by:
I have a couple questions about MySQL involving which version of MySQL to use. I'm looking for minimal memory use on a Windows XP machine. Which version would be best for this? And can anyone...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
5
by: news.telia.net | last post by:
Hi! I have a question. I have installed php and mysql on an apache-server on windows and I can't connect to the server. I tried to create a database (since I am trying to learn howto). My...
27
by: gerrymcc | last post by:
Hello, I'm a php/mysql beginner... Is there any way of making the mysql command line client full-screen? Sometimes it's easier to use the client than go thru php, but since it's only about 80...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.