Hey, I recently installed PHP v5.2.11 on my computer. (Windows XP Pro SP3) I downloaded the pre-compiled version (since I have no idea how to compile it on Win) and just finished my database class script, when I get this:
Fatal error: Call to undefined function mysql_connect() in C:\tg\includes\class.db.php on line 38
I thought ok, I'm a beginner at OO PHP, maybe I screwed something up in there. So I wrote a simple PHP file to connect and ran it on the command line (php "test.php") and it gave me the same error.
In PHP5, by default, mysql extension is not enabled. Locate your php.ini (path exposed through phpinfo()), and remove the ; at the beginning of the mysql.dll or mysql.so extension, and finally restart apache.
John Cartwright wrote:In PHP5, by default, mysql extension is not enabled. Locate your php.ini (path exposed through phpinfo()), and remove the ; at the beginning of the mysql.dll or mysql.so extension, and finally restart apache.
I looked and did not find it. In fact, I don't even have an \ext folder where the extensions are normally stored. (I'm on Windows, so it's .dll files)
I just googled and found a guide to compile PHP on Windows, so I might try that instead, but a fix is still appreciated if this doesn't work.
Last edited by sheppardzwc on Tue Dec 01, 2009 6:07 pm, edited 1 time in total.
John Cartwright wrote:Oops, it's actually called php_mysql.dll (not just mysql.dll). Give that a shot.
I decided I'd just uninstall the windows-installed PHP and use the zip package. It included all the ext\'s and it gave me a better experience in configuring it. Thank you for your help though John, much appreciated. (I'll use http://php.net/mysql from now on hehe)
Bah. I spoke too soon. I'm still having the issue.
My php.ini is as follows; (only extensions, if you need the whole copy, just ask)
; Windows Extensions
; Note that ODBC support is built in, so no dll is needed for it.
; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5)
; extension folders as well as the separate PECL DLL download (PHP 5).
; Be sure to appropriately set the extension_dir directive.
So whats the issue now? The extension exists in the extension folder, you removed the comment character for php_mysql.dll, but have you restarted apache?
If so, check your error logs which should tell you why the extension failed to load.
You probably either need to add your PHP directory to your path var or copy the mysql.dll (NOT php_mysql.dll) from the PHP dir to windows\system or windows\system32. Then restart apache. This is how I had to do it in the past but I haven't used windows in a while.
-Shawn
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
AbraCadaver wrote:You probably either need to add your PHP directory to your path var or copy the mysql.dll (NOT php_mysql.dll) from the PHP dir to windows\system or windows\system32. Then restart apache. This is how I had to do it in the past but I haven't used windows in a while.
-Shawn
Don't got enough money for a Linux VPS or Dedicated right now is why I'm using Windows. And it's a pain in the ass. But eh.
John Cartwight wrote:So whats the issue now? The extension exists in the extension folder, you removed the comment character for php_mysql.dll, but have you restarted apache?
If so, check your error logs which should tell you why the extension failed to load.
The extension_dir setting was set to "./" and all my extensions were located in the ext folder, so I changed it to "./ext" and it works perfectly now. Had to look in the apache logs to find it. Thanks.