Marco
Marco

Reputation: 57573

PHP doesn't see MySQL

I've already seen this post PHP doesn't see mysql extension, but it didn't help me.
I use:

In httpd.conf I configured Apache with PHP

PHPIniDir "C:\WEB\PHP\"
LoadModule php5_module "C:\WEB\PHP\php5apache2_2.dll"
ScriptAlias /php "C:/WEB/PHP/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php-cgi.exe"

In php.ini I set

extension_dir = "C:/WEB/PHP/ext/"
[PHP_MYSQL]
extension=php_mysql.dll
[PHP_MYSQLI]
extension=php_mysqli.dll

MySql is started and working, but PHP does not see mysql.
I've also tried to copy libmysql.dll into %windir%\system32 and restarted web server, but it didn't work.
If you need I can post other info.

UPDATE 1:
Running <?php phpinfo(); ?> I can only see mysqlnd, but not mysql nor mysqli.
If I run php -i I see

mysql

MySQL Support => enabled
Active Persistent Links => 0
Active Links => 0
Client API version => mysqlnd 5.0.8-dev - 20102224 - $Revision: 310735 $

UPDATE 2:
Apache, PHP and MySQL folders are the same of a previous working pc.
I copied them, reconfigured paths, installed and started services:

httpd -k install && httpd -k start
mysqld --install && net start mysql

UPDATE 3:

UPDATE 4:
I checked with Everything and the only php.ini I have on my pc is the one in php folder.

UPDATE 5:
I tried this code:

<?php
ini_set('display_errors', 'on');
error_reporting(E_ALL);
mysql_connect();
?>

and I get Fatal error: Call to undefined function mysql_connect() in C:\var\www\Apache\test.php on line 4

Upvotes: 2

Views: 5473

Answers (3)

Kalamun
Kalamun

Reputation: 429

I've fixed the same problem adding to the Environment Variable "Path" of Windows (System > Advanced > Environment Variables > Path) the following paths:

c:\Program Files\PHP5;C:\Program Files\MySQL\MySQL Server 5.5\lib

The first one is where php.ini is located, the second one (most important!) is where libmysql.dll is located (usually inside the "lib" directory inside the mysql installation dir)

This operations are quite well described in the PHP.net page http://php.net/manual/en/mysqli.installation.php

Now it works.

Upvotes: 3

AndrewR
AndrewR

Reputation: 6748

You need to move the extension=php_mysql.dll and extension=php_mysqli.dll lines in your php.ini file up. They should be with all the generic settings.

As far as I know, there is no section for php_mysql and php_mysqli, it's just mysql and mysqli, but those only contains specific settings for those modules. The actual extensions are loaded before those settings are read.

Upvotes: 1

Starx
Starx

Reputation: 78971

The most feasible and time saving option I see now, is to do the fresh installation of WAMP itself, and migrate the old files and dbs to the new one.

Upvotes: 0

Related Questions