Fatal error: Call to undefined function mysql_connect() with Windows Vista, PHP5, MySQL and Apache2

Terry picture Terry · Aug 19, 2012 · Viewed 15.5k times · Source

I am struggling to get PHP to connect to a MySQL database in an Apache environment. I have tried to solve this issue by myself, however, I am at the point of spending too much time on this issue with no resolution.

In my php.ini file, I have the following (after extensive research, this seemed to be the consensus of required INI statements):

; Directory in which the loadable extensions (modules) reside.
; extension_dir = "./"
extension_dir = "C:\php\ext"
extension=php5apache2_2.dll

extension=msql.dll
extension=php_mysql.dll
extension=php_mysqli.dll

mysql.default_port = 3607

mysqli.default_port = 3306

In my Apache httpd.conf file:

LoadModule php5_module "C:/php/php5apache2_2.dll"
ServerName localhost:80

DocumentRoot "C:/Apache2/htdocs"

AddType text/html .shtml
AddType application/x-httpd-php .php
AddType application/x-httpd-php .phtml

extension=php_msql.dll

PHPIniDir "C:/php"

I have PHP 5.2.17, Apache 2.2.22(Wind32), and MySQL 5.2.

PHP scripts work fine, including <?php phpinfo(); ?>. I can use the MySQL Workbench to create schemas, tables, scripts, etc.

I read somewhere (after hours of searching for answers) that if one does not see MSQL in the page from PHPInfo that something is installed incorrectly? I have re-installed as suggested to no avail. I have started/stopped services, rebooted regularly after changes to ensure that changes would be effected.

I am working on a laptop with Windows Vista. When I try to access MySQL, I get this fatal error:

Fatal error: Call to undefined function mysql_connect()

Any help for this installation rookie would be greatly appreciated!

Answer

Drew picture Drew · Sep 7, 2012

I had a similar problem. Turns out it wasn't loading the php.ini file from the php folder (Yeah dumb right) I checked the phpinfo which said...

"Configuration File (php.ini) Path" was set to "C:\Windows". Placed the php.ini in that directory, eh voila works.

... wish i had installed WAMP