syd75 Posted October 5, 2006 Share Posted October 5, 2006 mysql_connect() suddenly stopped working, after I've used php/mysql on the web server for a long time. It works when I run php scripts from the command line, but not on the web server.I have no idea what have happened. phpinfo no longer has any entry about mysql. I've checked php.ini and the extension_dir is set correctly and extension=php_mysql.dll is uncommented. I'm able to add/remove other extensions and see changes in phpinfo. But not with mysql.I've also tried replacing the php_mysql.dll and libmysql.dll with the ones from php-5.1.6-Win32.zip, to no avail.I run MySQL 5.0.20 and PHP 5.1.6 with Zend 3.0.0 on Apache 2.0.55 on Windows XP.Can anyone help me out here? Quote Link to comment https://forums.phpfreaks.com/topic/23077-mysql_connect-suddenly-stopped-working/ Share on other sites More sharing options...
Hi I Am Timbo Posted October 5, 2006 Share Posted October 5, 2006 Is MySQL running? Do you get an error? Quote Link to comment https://forums.phpfreaks.com/topic/23077-mysql_connect-suddenly-stopped-working/#findComment-104282 Share on other sites More sharing options...
syd75 Posted October 5, 2006 Author Share Posted October 5, 2006 Yes, mysqld-nt.exe is in the task manager. But all the databases have been deleted, because when nothing else worked I tried to reinstall MySQL. So when I run the very simple script:[code]<?php $db = mysql_connect("localhost", "root", "MyPassword"); mysql_select_db("forum", $db); echo mysql_error();?>[/code]from the command prompt, I get:[code]Unknown database 'forum'[/code]When I run it on the web server, I get:[code]Fatal error: Call to undefined function mysql_connect() in C:\Server\Apache2\htdocs\test.php on line 2[/code] Quote Link to comment https://forums.phpfreaks.com/topic/23077-mysql_connect-suddenly-stopped-working/#findComment-104292 Share on other sites More sharing options...
JaGeK Posted October 5, 2006 Share Posted October 5, 2006 [quote author=syd75 link=topic=110585.msg447208#msg447208 date=1160061452]mysql_connect() suddenly stopped working, after I've used php/mysql on the web server for a long time. It works when I run php scripts from the command line, but not on the web server.I have no idea what have happened.[/quote]What says PHP's error log in this regard? Quote Link to comment https://forums.phpfreaks.com/topic/23077-mysql_connect-suddenly-stopped-working/#findComment-104300 Share on other sites More sharing options...
thepip3r Posted October 5, 2006 Share Posted October 5, 2006 [quote]But all the databases have been deleted, because when nothing else worked I tried to reinstall MySQL. So when I run the very simple script:Unknown database 'forum'[/quote]um... forum no longer exists according to the mysql error. did you recreate your database and tables after you reinstalled mysql? Quote Link to comment https://forums.phpfreaks.com/topic/23077-mysql_connect-suddenly-stopped-working/#findComment-104305 Share on other sites More sharing options...
syd75 Posted October 5, 2006 Author Share Posted October 5, 2006 It says:[code]PHP Warning: PHP Startup: Unable to load dynamic library 'C:\Server\PHP\ext\php_mysql.dll'[/code]when I restart the web server. 'C:\Server\PHP\ext\php_mysql.dll' is there, so it has to be something that prevents it from loading. Quote Link to comment https://forums.phpfreaks.com/topic/23077-mysql_connect-suddenly-stopped-working/#findComment-104322 Share on other sites More sharing options...
syd75 Posted October 5, 2006 Author Share Posted October 5, 2006 [quote author=thepip3r link=topic=110585.msg447259#msg447259 date=1160064441]um... forum no longer exists according to the mysql error. did you recreate your database and tables after you reinstalled mysql?[/quote]No, I can't get phpMyAdmin working because of the problems above, so I haven't recreated the databases and tables yet. It might be an easy way to do this without phpMyAdmin also, but I have always used phpMyAdmin to do this. Quote Link to comment https://forums.phpfreaks.com/topic/23077-mysql_connect-suddenly-stopped-working/#findComment-104332 Share on other sites More sharing options...
wildteen88 Posted October 5, 2006 Share Posted October 5, 2006 Looks like something has been moved/changed as php is unable to initiate the mysql extension when loading up. Wheres is the your php.ini file located to and where is the libmysql.dll file located to?Is PHP using the correct php.ini? You can chekc by running the phpinfo() function and making sure that [b]Configuration File (php.ini) Path[/b] points to the correct location of the php.ini you're edting Quote Link to comment https://forums.phpfreaks.com/topic/23077-mysql_connect-suddenly-stopped-working/#findComment-104334 Share on other sites More sharing options...
syd75 Posted October 5, 2006 Author Share Posted October 5, 2006 php.ini is located in C:\Server\PHP which is the correct location according to phpinfo.The PHPIniDir in httpd.conf is also set to "C:/Server/PHP".This files in C:\Server\PHP are:fdftk.dllfribidi.dllgds32.dllgo-pear.batinstall.txtlibeay32.dlllibmcrypt.dlllibmhash.dll[b]libmysql.dll[/b]license.txtmsql.dllnews.txtntwdblib.dllphp-cgi.exephp-win.exephp.exephp.gif[b]php.ini[/b]php.ini-distphp.ini-recommendedphp5apache.dll[b]php5apache2.dll[/b]php5apache_hooks.dllphp5embed.libphp5isapi.dllphp5nsapi.dllphp5ts.dllpws-php5cgi.regpws-php5isapi.regsnapshot.txtssleay32.dllyaz.dll Quote Link to comment https://forums.phpfreaks.com/topic/23077-mysql_connect-suddenly-stopped-working/#findComment-104347 Share on other sites More sharing options...
thepip3r Posted October 5, 2006 Share Posted October 5, 2006 yes, check your PHP.ini file to see where your extensions directory is pointing to and verify that it's pointing to the actual path of where your extensions are loaded in PHP, make sure that you have the mySQL extension uncommented in your PHP.ini as well. One more thing, is 'C:\Server\PHP\ext\php_mysql.dll' a valid path? C:\PHP\ext\php_mysql.dll is where i see most paths referenced, not usually c:\server\php\ext... Quote Link to comment https://forums.phpfreaks.com/topic/23077-mysql_connect-suddenly-stopped-working/#findComment-104350 Share on other sites More sharing options...
wildteen88 Posted October 5, 2006 Share Posted October 5, 2006 Thats cool. Did you add your php folder to the Windows PATH variable?If you didnt then try copying libmysql.dll to C:\WINDOWSMake sure you restart Apache after. Quote Link to comment https://forums.phpfreaks.com/topic/23077-mysql_connect-suddenly-stopped-working/#findComment-104351 Share on other sites More sharing options...
syd75 Posted October 5, 2006 Author Share Posted October 5, 2006 Yes, everything is correct in php.ini. I installed php in "C:\Server\PHP" instead of the standard "C:\PHP", so the extension_dir is correct. It is also correctly reported in phpinfo. I'm able to comment/uncomment f.ex. extension=php_gd2.dll and see the changes. It is just php_mysql.dll that won't load.I had everything running fine for a long time without the php folder in the Windows PATH variable, or the libmysql.dll any other places than in the php folder. Now I have both the php folder in the Windows PATH variable and a copy of libmysql.dll in C:\WINDOW. I have restarted the computer and the web server. But there is still the same error. Quote Link to comment https://forums.phpfreaks.com/topic/23077-mysql_connect-suddenly-stopped-working/#findComment-104357 Share on other sites More sharing options...
wildteen88 Posted October 5, 2006 Share Posted October 5, 2006 Looks like PHP is finding an old libmysql.dll check that there isnt any other libmysql.dll files in C:\windows\system32Also when you added php to the Windows Path variable make sure you restarted your computer. PHP can be very fussy sometimes. There is a conflict with the libmysql.dll file somewhere and so you get the error you're getting. Quote Link to comment https://forums.phpfreaks.com/topic/23077-mysql_connect-suddenly-stopped-working/#findComment-104400 Share on other sites More sharing options...
syd75 Posted October 5, 2006 Author Share Posted October 5, 2006 [quote author=wildteen88 link=topic=110585.msg447355#msg447355 date=1160070586]Looks like PHP is finding an old libmysql.dll check that there isnt any other libmysql.dll files in C:\windows\system32[/quote]That was the problem. Thank you very, very much!!!I've never been to this forum before. But what a great forum! So many people so willing to help. Thanks to all of you! Quote Link to comment https://forums.phpfreaks.com/topic/23077-mysql_connect-suddenly-stopped-working/#findComment-104407 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.