Jump to content


Photo

mysql_connect() suddenly stopped working


  • Please log in to reply
13 replies to this topic

#1 syd75

syd75
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 05 October 2006 - 03:17 PM

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?

#2 Hi I Am Timbo

Hi I Am Timbo
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 05 October 2006 - 03:50 PM

Is MySQL running? 

Do you get an error?

#3 syd75

syd75
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 05 October 2006 - 04:01 PM

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:
<?php
	$db = mysql_connect("localhost", "root", "MyPassword");
	mysql_select_db("forum", $db);
	echo mysql_error();
?>

from the command prompt, I get:

Unknown database 'forum'

When I run it on the web server, I get:

Fatal error: Call to undefined function mysql_connect() in C:\Server\Apache2\htdocs\test.php on line 2


#4 JaGeK

JaGeK
  • Members
  • PipPip
  • Member
  • 20 posts
  • LocationNRW, Germany

Posted 05 October 2006 - 04:04 PM

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.


What says PHP's error log  in this regard?

#5 thepip3r

thepip3r
  • Members
  • PipPipPip
  • Advanced Member
  • 289 posts

Posted 05 October 2006 - 04:07 PM

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'

um... forum no longer exists according to the mysql error.  did you recreate your database and tables after you reinstalled mysql?

#6 syd75

syd75
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 05 October 2006 - 04:14 PM

It says:

PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\Server\PHP\ext\php_mysql.dll'

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.

#7 syd75

syd75
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 05 October 2006 - 04:19 PM

um... forum no longer exists according to the mysql error.  did you recreate your database and tables after you reinstalled mysql?


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.

#8 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 05 October 2006 - 04:23 PM

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 Configuration File (php.ini) Path points to the correct location of the php.ini you're edting

#9 syd75

syd75
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 05 October 2006 - 04:38 PM

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.dll
fribidi.dll
gds32.dll
go-pear.bat
install.txt
libeay32.dll
libmcrypt.dll
libmhash.dll
libmysql.dll
license.txt
msql.dll
news.txt
ntwdblib.dll
php-cgi.exe
php-win.exe
php.exe
php.gif
php.ini
php.ini-dist
php.ini-recommended
php5apache.dll
php5apache2.dll
php5apache_hooks.dll
php5embed.lib
php5isapi.dll
php5nsapi.dll
php5ts.dll
pws-php5cgi.reg
pws-php5isapi.reg
snapshot.txt
ssleay32.dll
yaz.dll


#10 thepip3r

thepip3r
  • Members
  • PipPipPip
  • Advanced Member
  • 289 posts

Posted 05 October 2006 - 04:41 PM

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...

#11 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 05 October 2006 - 04:41 PM

Thats cool. Did you add your php folder to the Windows PATH variable?

If you didnt then try copying libmysql.dll to C:\WINDOWS

Make sure you restart Apache after.

#12 syd75

syd75
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 05 October 2006 - 04:50 PM

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.

#13 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 05 October 2006 - 05:49 PM

Looks like PHP is finding an old libmysql.dll check that there isnt any other libmysql.dll files in C:\windows\system32

Also 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.

#14 syd75

syd75
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 05 October 2006 - 05:57 PM

Looks like PHP is finding an old libmysql.dll check that there isnt any other libmysql.dll files in C:\windows\system32


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!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users