Page 1 of 2
MySQL extension not loading
Posted: Tue May 30, 2006 5:52 pm
by qwasqaws
Yallo, I keep getting errors pertaining to the MySQL extensions not having been loaded. I've set up Apache, PHP and MySQL following a step by step tutorial and everything else worked fine. I looked around the net for the solution and did everything I could find and nothing worked. The extension line is uncommented in php.ini, the correct php.ini is being loaded, the extensions directory is correct and the windows PATH settings are correct. I'm new to the whole thing but I don't see what else it could be.
I have PHP 5.1.4 and MySQL 5.0.21.
Thanks in advance.
Posted: Tue May 30, 2006 8:34 pm
by bdlang
What specific errors are you getting? Can you connect to MySQL via command line vs PHP?
Posted: Tue May 30, 2006 8:59 pm
by RobertGonzalez
Which mysql library are you trying to use, mysql or mysqli?
Posted: Tue May 30, 2006 9:55 pm
by qwasqaws
Commandline seems to work fine.
Code: Select all
<?php
mysql_connect('localhost', 'root', '****');
mysql_select_database('mysql');
mysql_query('SELECT * FROM `user`') or die('Could not execute query: ' . mysql_error());
?>
Gives me:
Fatal error: Call to undefined function mysql_connect() in H:\web\public\index.php on line 2
Trying to load phpmyadmin gives me:
Cannot load mysql extension. Please check your PHP configuration. - Documentation
I don't know what MySQLI is so I'll assume that it's the basic MySQL.
Re: MySQL extension not loading
Posted: Tue May 30, 2006 10:10 pm
by RobertGonzalez
qwasqaws wrote:The extension line is uncommented in php.ini, the correct php.ini is being loaded, the extensions directory is correct and the windows PATH settings are correct. I'm new to the whole thing but I don't see what else it could be.
phpinfo() should tell you (right up at the top) what extensions are being loaded. Look for mysql or mysqli in that section. As of right now, there is either an uncommented php.ini extension line, there is no extension in the PHP\ext folder, or the path is wrong. Those are the usual things that report a call to an undefined function error.
Posted: Tue May 30, 2006 10:38 pm
by bdlang
Aside from what Everah mentioned, did you restart Apache after editing php.ini?
Posted: Tue May 30, 2006 10:46 pm
by qwasqaws
It doesn't say anywhere what extensions are loaded. What section should that be under? Theres no sqli anywhere so it must be sql.
I'm sure all the paths are correct. I even copied and pasted them to make sure I wasn't somehow overlooking a spelling error.
These are the lines in php.ini:
Code: Select all
extension_dir = "H:\web\PHP514\ext"
extension=php_mysql.dll
This is the link to the file:
H:\web\PHP514\ext\php_mysql.dll
All c+p'd. I even tried putting all the backslashes as forwardslashes. And yes, I restarted it after every change I made.
Posted: Tue May 30, 2006 10:57 pm
by RobertGonzalez
Do a system search for php.ini. On my windows system I have like seven different php.ini files. See how many there are in your system.
Posted: Tue May 30, 2006 11:06 pm
by qwasqaws
The only one I have is in the windows directory and phpinfo says that's the one it's reading.
php.ini-dist and php.ini-recommended are in the php folder but they're meant to be there right?
Posted: Tue May 30, 2006 11:15 pm
by RobertGonzalez
So that means that you should have php.ini, php.ini-dist and php.ini-recommended in your windows directory. Inside of the PHP folder, there should be a folder called \ext. Inside of that folder should be a file called php_mysql.dll or php_mysqli.dll. Whichever one is there is the line in your php.ini file that you need to uncomment.
Posted: Wed May 31, 2006 6:36 am
by jayshields
I've been helping him on MSN and it seems to all look OK to me. He's put the mysql .dll file in his ext folder and I don't think there is any need to copy php.ini dist and recommended anywhere, I think they are just dummy files incase you don't want to edit too much in your real php.ini.
He forgot to mention the MySQL service is running in services.msc too, not that I think that would cause the problem - I always thought call to undefined function errors were extension troubles.
He asked me earlier is there any config files which should point to the MySQL folder and I couldn't remember, maybe that could be the cause.
Posted: Wed May 31, 2006 8:39 am
by RobertGonzalez
There should be anything to do with config files unless you are changing mysql server start up variables. There's another thread going around on these forums in which a fellow has uncommented requested extensions in php.ini but still is having problems loading the extensions. I wonder if this guys problem was similar.
As long as his issues have been worked out, I supposed we should all be happy.

Posted: Wed May 31, 2006 10:10 am
by qwasqaws
Just doing some testing I uncommented some other extensions and they all appeared in phpinfo() except... I don't know if this means anything but when I uncommented all the sql related ones, msql, mssql, pgsql and sqlite and the only one that showed up in phpinfo() was pgsql. So how come it's just not loading them? It's obviously in the right directory and the lines are uncommented. What more does it need?
Posted: Wed May 31, 2006 10:24 am
by GM
Have you got the following lines uncommented in your php.ini?
Code: Select all
// MySQLi extension
extension=php_mysqli.dll
I seem to remember reading somewhere that from a certain version of mySQL, you need to use the mysqli.dll extension.
Posted: Wed May 31, 2006 10:30 am
by qwasqaws
Same outcome as php_mysql. Doesn't work or appear in phpinfo. This is rather baffling.