MySQL extension not loading
Moderator: General Moderators
MySQL extension not loading
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.
I have PHP 5.1.4 and MySQL 5.0.21.
Thanks in advance.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Commandline seems to work fine.
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.
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());
?>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.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: MySQL extension not loading
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.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.
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:
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.
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.dllH:\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.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
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.
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
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.
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.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
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.
As long as his issues have been worked out, I supposed we should all be happy.
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?
Have you got the following lines uncommented in your php.ini?
I seem to remember reading somewhere that from a certain version of mySQL, you need to use the mysqli.dll extension.
Code: Select all
// MySQLi extension
extension=php_mysqli.dll