New Installation error - "PHP has not been properly configured with the MySQL extension so that it can communicate with MySQL. Please check your php.ini file or recompile PHP"

New Installation error - "PHP has not been properly configured with the MySQL extension so that it can communicate with MySQL. Please check your php.ini file or recompile PHP"

by Lisa Miller -
Number of replies: 5
I am trying to install moodle on a shared windows hosting account with aplus.net. I have to use a windows account due to other applications that we need to run in addition to moodle. If there is a php.ini file I do not have access to it, so I have not been able to check the extensions. I did run phpinfo and I have attached the results.

I am installing the latest stable version of Moodle, and using
MySQL client version: 5.0.51a.
and I think it is IIS 7.0

Any help would be greatly appreciated, and just a reminder technical support for the hosting company has said I do not have access to php.ini.
Average of ratings: -
In reply to Lisa Miller

Re: New Installation error - "PHP has not been properly configured with the MySQL extension so that it can communicate with MySQL. Please check your php.ini file or recompile PHP"

by Nicolas Dunand -
Picture of Core developers Picture of Plugin developers
Hello,

From the phpinfo supplied, it seems your PHP installation (I mean, the one from your hosting company) has no support for MySQL (in phpinfo, the "configure command" should at least contain something like "--with-mysql").

You should ask your hosting company if they provide any database management system working with PHP, and with Moodle 1.9 you'll need it to be MySQL or Postgres7.

From what I see from your phpinfo I would say there could be none of these. Probably MSSQL is supported, but I'm unsure if Moodle supports it ... I think not.
In reply to Nicolas Dunand

Re: New Installation error - "PHP has not been properly configured with the MySQL extension so that it can communicate with MySQL. Please check your php.ini file or recompile PHP"

by Nicolas Dunand -
Picture of Core developers Picture of Plugin developers
Er ... my mistake. rouge

As of Moodle 1.7, you are able to use the following Database Management Systems for your Moodle : MySQL 4.1.16 or Postgres 8.0 or MSSQL 9.0 or Oracle 9.0.

So, if your hosting company provides php-mssql binding (which seems to be the case according to your phpinfo), you should be able to configure your Moodle with MSSQL during installation.

So, basically, you should just ask them about the parameters to connect to a MSSQL database (e.g. username, password, and hostname), and this should be enough to get your Moodle running.
In reply to Lisa Miller

Re: New Installation error - "PHP has not been properly configured with the MySQL extension so that it can communicate with MySQL. Please check your php.ini file or recompile PHP"

by Richard Enison -
LM,

ND's info is correct as far as it goes but not totally relevant if you really do want to use MySQL, as your post says, rather than MSSQL (which is a good idea if you ask me; there are way more porblems reported trying to get MSSQL to play nice with Moodle than MySQL). Your phpinfo does indeed show that PHP is not configured with the MySQL extension, as your error msg. says and as ND pointed out. However, it is not correct that you need to recompile PHP to accomplish this configuration. With Windows, I'm pretty sure, what you need to do is enable the extension in php.ini.

The phpinfo also tells us that the active php.ini file is in c:\windows. It says you are using PHP5 (5.2.3 to be exact), which means there is only one active php.ini file at a time. Since you are using shared hosting, you're right, you don't have access to the file. It belongs to aplus.net and applies to all their clients. However, many web hosts provide ways for their clients to alter the way PHP is configured for their individual accounts, usually with .htaccess files (for Apache only so if your site is using IIS this does not apply) or custom php.ini files. Each host has its own way of providing for custom php.ini capability, if at all.

I just visited aplus.net to find out if they support custom php.ini, and found a knowledge base article that suggests dynamically loading the MySQL extension using the PHP function dl. You can find it at this link. I would add it to the config.php file in the top-level Moodle directory.

RLE
Average of ratings: Useful (1)
In reply to Richard Enison

Re: New Installation error - "PHP has not been properly configured with the MySQL extension so that it can communicate with MySQL. Please check your php.ini file or recompile PHP"

by Lisa Miller -
Hello RLE,

Thank you for your thorough response. Sorry for my delay in getting back, I have been out of town.

Because the original error occurs before the installer can complete the creation of the config.php page I went ahead and created it and copied it over to the server and I inserted the code from the aplus KB as you suggested. Now when I hit next on the installer, I get a blank page. Just to be clear, I am hitting next on the area where the installer would complete the config.php page but I have already added it to the moodle directory on the host, the address of the page that comes up is /moodle/index.php. When this happened I went back and added the debug code to the bottom of the config.php page:

ini_set ('display_errors', 'on');
ini_set ('log_errors', 'on');
ini_set ('display_startup_errors', 'on');
ini_set ('error_reporting', E_ALL);
$CFG->debug = DEBUG_ALL;

but I still get a blank page and don't know where to find the errors. Is this making sense? I am attaching my config.php page with a few areas "greyed" out, in case you need that information.

Thank you,

Lisa Miller
In reply to Lisa Miller

Re: New Installation error - "PHP has not been properly configured with the MySQL extension so that it can communicate with MySQL. Please check your php.ini file or recompile PHP"

by Richard Enison -
LM,

OK. I've looked at your attachment and it looks okay, mostly. More about that later.

I should have realized that your installation process had not gotten to the point where it created config.php. If I had, I would have suggested temporarily inserting the script from the knowledge base article somewhere else, like install.php. Also, I just noticed that your phpinfo page does indicate that you are, in fact, using IIS (IIS 7.0 to be exact). This is near the end of the page, in the row for ENV["SERVER_SOFTWARE"].

The main problem I see in the config.php file you attached is in the line that begins $CFG->dirroot. It contains a quotation that begins with a double quote and ends with a single quote. Try changing the double quote to a single quote.

Aside from that, you have inserted code to turn debugging on and logging of errors, but that won't do you much good until you look for errors in the log. If you don't know where the error log is, you can find out (if it is set as the pathname of a file) by adding this line to config.php:

echo 'Error log = ' . ini_get('error_log') . "\n";

Or better still, you can set the parameter with ini_set, e.g.

ini_set('error_log', 'c:\php\errlog.txt');

I would suggest inserting this line right after your other ini_set lines.

EDIT: You might also want to move the block of debug lines at the bottom of config.php to the top, before the

if (!extension_loaded('mysql')) {

line. That way, if there is a problem with that part of the script, any error generated will be logged.

RLE