undefined function mysql_connect()... Eeek!
Sometime ago I reinstalled my main PC, which I run Windows on. I do most of my work on here, but recently I haven't had any time to do anything web-related.
I am currently working on a web-site and I noticed I hadn't finished setting everything up again. Anything else I've been playing around with recently has been on my Linux box which I have Apache 2.2, PHP 5 and MySQL 5.1 running.
Although this time I decided to just use my environment on my PC. After some playing about I noticed I couldn't get any data from a database due to the error:
"undefined function mysql_connect()"
Which threw me a bit, as I can never remember having to configure MySQL to work with PHP. So I went to add the DLL to the PHP.INI (which incidently is in the PHP install dir, and not the WINDOWS dir).
After restarting Apache I got the following error "php_mysql.dll - The specified module could not be found." Which wasn't nice. After a bit of relative/absolute path tinkering in the PHP.INI file the error message was adjusted to:
"php_mysql.dll - The specified procedure could not be found."
Slightly different and a dead giveaway. As it is no longer the module that can't be found but the procedure it indicates that the client library that is being used isn't compatible.
Question is, why would there be an incompatible MySQL module bundled with PHP?
Answer, there isn't. The problem I had was the client library "libmysql.dll" was being used from my MySQL installation, which happens to have the "bin" directory in my PATH (this means I can just type "mysql" into a command prompt to connect locally). I just overwrote this file with the one that came bundled with PHP and all my problems were solved.
I really ought to update my MySQL daemon on this machine, but that's just another thing to add to the list.
I am currently working on a web-site and I noticed I hadn't finished setting everything up again. Anything else I've been playing around with recently has been on my Linux box which I have Apache 2.2, PHP 5 and MySQL 5.1 running.
Although this time I decided to just use my environment on my PC. After some playing about I noticed I couldn't get any data from a database due to the error:
"undefined function mysql_connect()"
Which threw me a bit, as I can never remember having to configure MySQL to work with PHP. So I went to add the DLL to the PHP.INI (which incidently is in the PHP install dir, and not the WINDOWS dir).
After restarting Apache I got the following error "php_mysql.dll - The specified module could not be found." Which wasn't nice. After a bit of relative/absolute path tinkering in the PHP.INI file the error message was adjusted to:
"php_mysql.dll - The specified procedure could not be found."
Slightly different and a dead giveaway. As it is no longer the module that can't be found but the procedure it indicates that the client library that is being used isn't compatible.
Question is, why would there be an incompatible MySQL module bundled with PHP?
Answer, there isn't. The problem I had was the client library "libmysql.dll" was being used from my MySQL installation, which happens to have the "bin" directory in my PATH (this means I can just type "mysql" into a command prompt to connect locally). I just overwrote this file with the one that came bundled with PHP and all my problems were solved.
I really ought to update my MySQL daemon on this machine, but that's just another thing to add to the list.