AllenBoone Posted December 17, 2009 Share Posted December 17, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/185519-cannot-setup-mysql-with-php-53/ Share on other sites More sharing options...
trq Posted December 17, 2009 Share Posted December 17, 2009 This is all to do with licensing issues. There is a faq in the mysql installation manual page (here) that explains. Since 5.3 there is now a native driver enabled by default. Quote Link to comment https://forums.phpfreaks.com/topic/185519-cannot-setup-mysql-with-php-53/#findComment-979501 Share on other sites More sharing options...
AllenBoone Posted December 17, 2009 Author Share Posted December 17, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/185519-cannot-setup-mysql-with-php-53/#findComment-979546 Share on other sites More sharing options...
PFMaBiSmAd Posted December 17, 2009 Share Posted December 17, 2009 Have you checked if the php.ini that you are changing is the one that php is using (its the phpinfo() output Loaded Configuration File line) and did you stop and start the web server to get any changes made to the php.ini to take effect? Quote Link to comment https://forums.phpfreaks.com/topic/185519-cannot-setup-mysql-with-php-53/#findComment-979549 Share on other sites More sharing options...
trq Posted December 18, 2009 Share Posted December 18, 2009 You shouldn't need to edit your php.ini. The new native driver is loaded by default. What does phpinfo say about mysql? Quote Link to comment https://forums.phpfreaks.com/topic/185519-cannot-setup-mysql-with-php-53/#findComment-979563 Share on other sites More sharing options...
AllenBoone Posted December 18, 2009 Author Share Posted December 18, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/185519-cannot-setup-mysql-with-php-53/#findComment-979646 Share on other sites More sharing options...
PFMaBiSmAd Posted December 18, 2009 Share Posted December 18, 2009 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.) Quote Link to comment https://forums.phpfreaks.com/topic/185519-cannot-setup-mysql-with-php-53/#findComment-979647 Share on other sites More sharing options...
AllenBoone Posted December 18, 2009 Author Share Posted December 18, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/185519-cannot-setup-mysql-with-php-53/#findComment-979662 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.