Jump to content

Cannot Setup MySQL with php 5.3


AllenBoone

Recommended Posts

Hello. I recently installed MySQL 5.1 and php 5.3, but I cannot get the two to work together. They are being used on an Apache 2.2 server on my Windows Vista Home Premium machine (this is not a live server; I'm just using it to test stuff). Most installation documentation I've seen says I need a libmysql.dll file in my php directory, but it was not included in the 5.3 zip file I downloaded from php.net. I've also configured my windows PATH to point to C:/php, and I've altered the php.ini file to include "extension=php_mysql.dll" and "extension_dir="C:/php/ext"". I've been testing my setup by using a file containing the following code:

 

<?php
// hostname or ip of server (for local testing, localhost should work)
$dbServer='localhost';

// username and password to log onto db server
$dbUser='root';
$dbPass='';

// name of database
$dbName='test';

    $link = mysql_connect("$dbServer", "$dbUser", "$dbPass") or die("Could not connect");
    print "Connected successfully<br>";
    mysql_select_db("$dbName") or die("Could not select database");
    print "Database selected successfully<br>";

// close connection
mysql_close($link);
?>

 

And trying to open it gives the following message:

 

Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\mysql_test.php on line 12

 

I'm not sure what to do. I've scoured Google for answers, but nothing has helped. I've read that php 5.3 handles MySQL differently than past versions, but I haven't been able to find what I need to do to fix it. Please help.

Link to comment
Share on other sites

Thank you for replying. I've followed the instructions in that link, but it doesn't work. The article says that I need libmysql.dll, and the article linked there says it's included in the zip. But it isn't. If I need it, how do I get it, and what do I do with it? If I don't need it, what do I need to do to get MySQL working with php on my system?

Link to comment
Share on other sites

Hmm, it says the loaded configuration file is (none), but the Configuration File Path is listed as C:\Windows, which is where the one I've been editing is located. Should I do something differently? Also, I have restarted both the server and my PC several times, but if I'm editing the wrong file, I don't suppose it matters.

 

Regarding mysql, phpinfo() says the following:

 

mysqlnd

Version: mysqlnd 5.0.5-dev - 081106 - $Revision: 289630 $

Command buffer size: 4096

Read buffer size: 32768

Read timeout: 31536000

Collecting statistics: Yes

Collecting memory statistics: No

 

In another box, titled Client Statistics, just below the other one, it has several fields each with the value 0.

Link to comment
Share on other sites

mysqlnd is just the driver. The actual mysql or mysqli extension still needs to be enabled.

 

Did you place a PHPIniDir setting in your http.conf that points to the php.ini, which should in fact be left in the original directory (you should not be and don't need to be copying files around to different folders.)

Link to comment
Share on other sites

Wow, I feel pretty dumb right now. I checked the http.conf, and the PHPIniDir was set to C:/php. One of the installation instructions I had tried to follow told me to move it to the Windows folder, but I should've noticed where I had it directed in http.conf file. It seems to be working now. Somewhat, at least. The code I posted above gives me an error message, but I think it's at least finding MySQL now. I'll probably try to puzzle out the problem tomorrow, but here's the message in case someone knows the problem offhand:

 

Warning: mysql_connect() [function.mysql-connect]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\mysql_test.php on line 12

 

Warning: mysql_connect() [function.mysql-connect]: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\mysql_test.php on line 12

 

Fatal error: Maximum execution time of 60 seconds exceeded in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\mysql_test.php on line 12

 

Thanks for the help fixing the MySQL setup. I probably wouldn't have noticed that for a long time if you had mentioned moving the file.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.