Jump to content


Photo

[SOLVED] Frustrated by - Cannot load mysql extension. Please check your PHP configuration


  • Please log in to reply
17 replies to this topic

#1 bondbloke

bondbloke

    Newbie

  • New Members
  • Pip
  • 9 posts
  • LocationEdinburgh - Scotland

Posted 27 June 2008 - 04:15 AM

I am a relative newcomer to setting up a server, but I am by no means stupid and can follow instructions reasonably well, especially when written in an understandable form; and if I don't understand something then I google it to find the relevant information.

I am trying to set up Apache, MySQL, PHP and PhpMyAdmin on my laptop in order to be able to work away with stuff whilst travelling. Now everything works well until it comes to the final stage - PhpMyAdmin... All I get from PhpMyAdmin is:-


Cannot load mysql extension. Please check your PHP configuration.


I have trawled many websites and forums looking for an answer and have found not one that doesn't tell me to do what I have already done: uncomment the relevant extensions, ensure the extension_dir is correctly entered in the php.ini file etc. etc. As I say I am not stupid and worked all of this out before I started, it's called forward planning; but still I get this bloody stupid error message and can't for the life of me work out what the hell is wrong...

FYI I am using:-

Apache 2.2_9
MySQL 5.0.5
PHP 5.2.6
PhpMyAdmin 2.11.7

HELP!!!!!
The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it. (Terry Pratchett)

#2 PFMaBiSmAd

PFMaBiSmAd

    Advanced Member

  • Staff Alumni
  • 16,767 posts
  • LocationColorado, U.S.A.

Posted 27 June 2008 - 09:43 AM

Check your web server error log file for any related messages. If there is a message about not being able to load the mysql dll, then the problem is as follows -

There is at least one auxiliary .dll that the mysql extension uses. The best method to get it to be accessible is to add the path to your php folder to the Windows PATH statement (re-boot your computer or re-logon as yourself to get any changes made to the Windows PATH statement to take effect.)

If there are no mysql related messages in the error log, then you need to make sure that the php.ini that you are changing is the one that php is using. Also, stop and start your web server to get any changes made to php.ini to take effect.
Signature: (not a comment about anything you posted unless specifically indicated)
Debugging step #1: To get past the garbage-out equals garbage-in stage in your code, you must check that the inputs to your code are what you expect.

Programming is just problem solving, but it is done in another language. You must learn enough of the programming language you are using to be able to read and write code.

#3 bondbloke

bondbloke

    Newbie

  • New Members
  • Pip
  • 9 posts
  • LocationEdinburgh - Scotland

Posted 27 June 2008 - 10:18 AM

Ok,

I checked the Apache error log and everything there seems to be fine, no mention of any mysql related errors at all...

The php.ini file I am using is the one that came in the .zip file (php.ini.recommended) and which I duly renamed php.ini, then modified as per the instructions in the PHP Documentation...

I have also just tried replacing the libmysql.dll as was suggested on one website I looked at, but this also has had no effect whatever.

Baffled ???  ???  ???
The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it. (Terry Pratchett)

#4 wildteen88

wildteen88

    Advanced Member

  • Staff Alumni
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 27 June 2008 - 12:56 PM

Does the mysql_* functions work fine in a standalone script: eg:
<?php

echo 'Connecting to MySQL server...';

mysql_connect('localhost', 'root', '') or die(' FAILURE!<br />Error: ' . mysql_error());

echo ' SUCCESS!<br />';

echo 'Selecting \'mysql\' Database...';
mysql_select_db('mysql') r die(' FAILURE!<br />Error: ' . mysql_error());

echo 'SUCCESS!<br />MySQL extension is loaded and working fine';

?>
If the above code display errors, such as undefined function mysql_connect, or all you get is  Connecting to MySQL server... and nothing else is displayed then the mysql extension is not loaded.

There could be many reasons why this could be. The first thing to do is to see of PHP is actually using the php.ini that you are edting, to test this simply run the phpinfo() function within a script, then run the script. Next Search for a line that starts with Loaded Configuration File. To the right of that line will be the full path to the php.ini PHP has loaded for configuration. If no path is stated then PHP is not reading the php.ini you are editing and thus PHPMyAdmin is displaying the above error.

To fix this, do as PFMaBiSmAd said, add PHP to the PATH Environment Variable. After doing this restart Windows. After Windows has booted rerun the phpinfo script and check to see if the php.ini has loaded.

Also avoid moving files outside of the PHP installation folder, this can cause more problems then needs be - especially when you upgrade PHP later on.

#5 bondbloke

bondbloke

    Newbie

  • New Members
  • Pip
  • 9 posts
  • LocationEdinburgh - Scotland

Posted 27 June 2008 - 04:38 PM

Nice one, I hadn't thought of checking the it is possible to connect to MySQL...

Unfortunately this does not seem to be the solution, the connection to My SQL seems fine all I get is the error|:-

Parse error: syntax error, unexpected T_STRING in C:\server\Apache2\htdocs\mysql.php on line 10

which is this line:-

mysql_select_db('mysql') r die(' FAILURE!<br />Error: ' . mysql_error());

still baffled (but at thisn time it may be alcohol, so I will trey again in the moprning)
The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it. (Terry Pratchett)

#6 gijew

gijew

    Advanced Member

  • Members
  • PipPipPip
  • 240 posts
  • LocationCalifornia

Posted 27 June 2008 - 04:42 PM

mysql_select_db('mysql') r die(' FAILURE!
Error: ' . mysql_error());


should be

mysql_select_db('mysql') or die(' FAILURE!
Error: ' . mysql_error());

I'm considered good looking in some countries

#7 bondbloke

bondbloke

    Newbie

  • New Members
  • Pip
  • 9 posts
  • LocationEdinburgh - Scotland

Posted 28 June 2008 - 03:52 AM

I did say that the result was probably alcohol related, I didn't even spot the typo...

I just tried again with this result:-

Connecting to MySQL server...
Fatal error: Call to undefined function mysql_connect() in C:\server\Apache2\htdocs\mysql.php on line 5


Which is :-

mysql_connect('localhost', 'root', '******') or die(' FAILURE!<br />Error: ' . mysql_error());

So I assume that php is not making the connection due to not loading the extension.

Loaded Configuration File = C:\server\php\php.ini

and it is till in the php directory, I had read elswehere that moving it could cause problems, so I didn't

Looking for a suitable brick wall to bang head against!
The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it. (Terry Pratchett)

#8 wildteen88

wildteen88

    Advanced Member

  • Staff Alumni
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 28 June 2008 - 08:25 AM

Have you added the PHP folder to the path environment variable, which was suggested earlier.

If its still doesn't load the extension, then PHP is most probably having difficulty finding the libmysql.dll library, which is required in order for the mysql extension to function. The libmysql.dll should be located in the root of your PHP folder. PHP should be able to find this file if PHP is added to the path environment variable.

Make sure you don't have any files such as php_mysql.dll or libmysql.dll outside of the php folder, check in places such as C:\Windows, C:\Windows\System32 etc. If you find any remove them as they will interfere.

#9 bondbloke

bondbloke

    Newbie

  • New Members
  • Pip
  • 9 posts
  • LocationEdinburgh - Scotland

Posted 28 June 2008 - 09:13 AM

The one thing I had missed was adding my php folder to the path environment - is now done...

Have made sure that the libmysql.dll is in the root of my php folder - it is...

Have also checked for rogue .dll files and found none at all...

Net Result = phpMyAdmin still returns:-

Cannot load mysql extension. Please check your PHP configuration.


Maybe I should just throw myself under a passing bus!
The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it. (Terry Pratchett)

#10 wildteen88

wildteen88

    Advanced Member

  • Staff Alumni
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 28 June 2008 - 11:02 AM

Ensure you have restarted Windows after modifying the PATH. Also clear your browsers cache too, incase your browser is loading an older page.

Make sure you have uncommented the correct extension, within the php.ini PHP5 comes with two extensions for mysql. These being php_mysql.dll and php_mysqli.dll

PHPMyAdmin can be configured to work with either extension. However the default is php_mysql.dll

Also when you installed PHP what media did you use? If you used the installer then I recommend you to go to php.net and download the zipped binaries package. Extract the contents of the zip to where PHP is currently installed to, overwriting existing files/folders. The installer comes with limited files.

#11 bondbloke

bondbloke

    Newbie

  • New Members
  • Pip
  • 9 posts
  • LocationEdinburgh - Scotland

Posted 28 June 2008 - 11:18 AM

Modified PATH did a restart - check

Cleared browser cache - check

Checked once more that I uncommented the right extensions in php.ini - check

Installed php from zipped binaries package (as am aware installer is rubbish) - check

Net Result = No Change

PHPMyAdmin can be configured to work with either extension. How??? Just to check I have not made a booboo there...

Or perhaps it would be as well to go back to the drawing board and begin from the beginning, wiping out all of the files in the process before re-installing everything...

GRRRRRRRRRRRRRR!!!!!
The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it. (Terry Pratchett)

#12 wildteen88

wildteen88

    Advanced Member

  • Staff Alumni
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 28 June 2008 - 11:28 AM

Can you attach the output of phpinfo here. I admit this is the most frustrating part of installing AMP manually, I have ran into this road block many times before.

#13 PFMaBiSmAd

PFMaBiSmAd

    Advanced Member

  • Staff Alumni
  • 16,767 posts
  • LocationColorado, U.S.A.

Posted 28 June 2008 - 11:48 AM

I was going to suggest a folder/files permission problem, but there would be an error in the error log about not being able to load the extension or there would be an actual permission error message in the error log.

Here is everything (off of the top of my head) that needs to be in place for the mysql extension to work -

Php needs to be loading the php.ini that you are changing.

php.ini needs an extension_dir = setting that points to where the main extension .dll files are located.

php.ini needs to have the line extension=php_mysql.dll uncommented.

The php_mysql.dll needs to be present in the folder pointed to by the extension_dir = setting in php.ini

The auxiliary libmysql.dll file that mysql uses needs to be in a folder that is on the Windows PATH statement.

All the .dll files need to be of the same version.

Stop and start your web server to get any changes made to any of the above items to take effect.

Is the basic mysql_connect php code working or still giving the undefined function message? Get that to work before worrying about phpmyadmin.
Signature: (not a comment about anything you posted unless specifically indicated)
Debugging step #1: To get past the garbage-out equals garbage-in stage in your code, you must check that the inputs to your code are what you expect.

Programming is just problem solving, but it is done in another language. You must learn enough of the programming language you are using to be able to read and write code.

#14 bondbloke

bondbloke

    Newbie

  • New Members
  • Pip
  • 9 posts
  • LocationEdinburgh - Scotland

Posted 28 June 2008 - 12:15 PM

PFMaBiSmAd: Have done all of those things with a net result of 0!

Have attached the output of phpinfo()

That passing bus is beginning to look more and more inviting...


[attachment deleted by admin]
The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it. (Terry Pratchett)

#15 wildteen88

wildteen88

    Advanced Member

  • Staff Alumni
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 28 June 2008 - 12:26 PM

Your extension_dir directive is not set correctly by looks of it. As your phpinfo output seem a little screwed (unless its Word playing up).

Set extension_dir like
extension_dir = "C:/server/php/ext";



#16 bondbloke

bondbloke

    Newbie

  • New Members
  • Pip
  • 9 posts
  • LocationEdinburgh - Scotland

Posted 28 June 2008 - 12:50 PM

Well bugger me backwards with a big stick!!!!!

GENIUS

I looked at that several times and had convinced myself that it was OK - a simple case of not seeing the wood for the trees!

Looks like I don't need to throw myself under that bus after all - I might just open a bottle of cold white...

Thanks everyone for the help, especially the genius that is wildteen88... ;D ;D ;D ;D ;D
The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it. (Terry Pratchett)

#17 wildteen88

wildteen88

    Advanced Member

  • Staff Alumni
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 28 June 2008 - 12:57 PM

Glad everything is sorted.

My tip is to use / rather than \ in directory paths. \ is seen as an escape character.

#18 bondbloke

bondbloke

    Newbie

  • New Members
  • Pip
  • 9 posts
  • LocationEdinburgh - Scotland

Posted 28 June 2008 - 01:41 PM

Yes I sort of figured that from the PHP book I have, but still didn't notice that I got it arse about face, so to speak.

A BIG THANKS


The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it. (Terry Pratchett)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com