April 27, 2012

PHP doesn't see MySQL

Question by Marco

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

  • Windows Seven (both 32bit in a VM and 64bit on a real pc)
  • Apache 2.2 with SSL
  • PHP 5.3.8
  • MySql 5.5.23

In httpd.conf I configured Apache with PHP

PHPIniDir "C:WEBPHP"
LoadModule php5_module "C:WEBPHPphp5apache2_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:

  • I’m able to use mysql through a DOS console
  • If I try to run an existing PhpMyAdmin I get The mysql extension is missing. Please check your PHP configuration.

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:varwwwApachetest.php on line 4

Answer by Starx

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.

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!