MYSQL PHP connection failed

I’m good to go now. I uninstalled Apache and MySQL and installed WAMP. Though the book says not too (suggests not to atleast), you can still function. Thanks for the help!

MySQL must not be running, or you are using the wrong username/password, or wrong port or something.

Download and install HeidiSQL. This is a free GUI front-end to MySQL for Windows.

Once you get it installed, connect. If it connects, you know MySQL is working.

If you haven’t changed the password, use username “root”, and password blank.

Kronso, is this in response to the most recent posts or a response to the problems CMW and I were having before?

Hello! Sorry about that. My response was to CMW. It just seems to me that’s a good way to test a database connection.

Regards,
kronso

Kronso,
Thank you. Whether Mysql was running could have been and was a key factor. Checking the php.ini as advised by ScallioXTX was also excellent and finally moving libmysql.dll file to an accessable directory resolved the issue. Long necks suggestion to move it to apache\bin directory was appeciated and followed. Sounds like sdavis is running now and that is good.
Thanks to all of you for a rewarding and enlightening experience.

Is there some protocol I should be following now that this issue has been resolved?

Thanks again,
CMW

I read all the posts. The suggestions did not work. I reinstalled MySQL and Apache. Now I don’t even get a error message anymore although the index.php file was opened: I put in an extra message, and the source code confirmed the opening of the file.
I installed phpMyAdmin (p. 314) to find out if I can connect with the mysql database. The phpMyAdmin window (figure 10.1) reported aside form the warning about the mcrypt extension also a message ‘cannot load the mysql-extension’.
Can sombody help me please?
Thanks Antoon.

Antoon, you didn’t say what OS you are running. If it is Windows, your PHP directory should have a subdirectory called ‘ext’. That subdirectory should contain a DLL that has the driver that allows PHP to connect to MySQL. For example: php_mysql.dll.

If in doubt, use the PHP installer EXE file for Windows. As you go through the installation process, make sure to check the items for MySQL and PDO. That way they will be installed.

No problem Kronso… it looks like you can still help someone though. :slight_smile:

Hello kronso and sdavis,
Thanks for the responses.

I spent a couple of hours checking everything, and going through all Kevin wrote in his book. And then, when no warnings appeared I discovered a spelling error in my php-file (ouput in stead of output, and ijbd in stead of ijdb). So I could connect with mysql and the joke database.
As for the problem I encountered with phpMyAdmin, I leave that for the appropriate moment.
Right now, I’ll cary on with p. 123.
Tahnks again and geretnigs form Antoon.

PS I suppose there is a time difference. As far as I know, I mailed the above respons sometime late at night. At this moment it is 6 pm (18.00) in Holland.

I’m in Iraq. There are plenty of time differences in this one thread lol.

Congrats on getting everything straightened out. I’m currently on page 197… the start of Chapter 7. I don’t know if this book could have been written any better… seriously.

Hi sdavis,
I couldn’t agree more.

now I’ve got the exact same problem !!

SDAVIS, CSW, are you out there! did you guys ever get this fixed?

just discovered this topic runs on for three pages, I had only read the first.

will try connection again tomorrow, and hopefully will not be back anytime soon :slight_smile:

LONGNECK nailed it ! being new to all this I don’t quite understand, but doing the below fixed things for me. many MANY thanks LONGNECK !!

I’m hoping that someone can assist me with this. I have been experiencing the same issues as sdavis and cmw. I followed the suggestions all the way up to and including moving libmysql.dll to apache/bin and the error that I receive now is:

Warning: mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user ‘root’@‘localhost’ (using password: YES) in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\connect\index.php on line 2

Unable to connect to the database server.

Can anyone troubleshoot this?

Hi kjt4eva,
I have a couple of suggestions
First of all check your spelling. The past week I discovered that in a not-running file, I typed Slink in stead of an $link. This difference was very hard to notice in my editor (dreamweaver 8). I discovered my error by copying and pasting a couple of lines from the corresponding file I downloaded from the code archive on the website of the book (see page xxiv) untill the file did work.
As for dreamweaver I made a 2-3 files with it looking exactly like the ones from the archive, but that did not run. Even when I put lines from the archive file in it.
Beware not to run/test your file from dreamweaver. See Kevin’s comments on pages 14 and 51.
Good luck.

Another way, which doesn’t require any copying of the libmysql.dll file is to simply add C:/PHP to the Windows PATH variable.