Jump to content

mysql_connect() suddenly stopped working


syd75

Recommended Posts

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?
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

[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?
Link to comment
Share on other sites

[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?
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

[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.
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
[b]libmysql.dll[/b]
license.txt
msql.dll
news.txt
ntwdblib.dll
php-cgi.exe
php-win.exe
php.exe
php.gif
[b]php.ini[/b]
php.ini-dist
php.ini-recommended
php5apache.dll
[b]php5apache2.dll[/b]
php5apache_hooks.dll
php5embed.lib
php5isapi.dll
php5nsapi.dll
php5ts.dll
pws-php5cgi.reg
pws-php5isapi.reg
snapshot.txt
ssleay32.dll
yaz.dll
Link to comment
Share on other sites

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...
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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