Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call to undefined function mysql_connect

Tags:

I just installed PHP and Apache on my home PC. When I try to call function mysql_connect I get:

fatal error: call to undefined function mysql_connect. 

I have loaded php.ini where I have uncommented lines extension=php_mysql.dll and extension=php_mysqli.dll and changed extension directory to extension_dir = "C:\php\ext" - which is the directory where files php_mysql.dll and php_mysqli.dll are. How can I fix this problem?

Output of phpinfo(): http://jsfiddle.net/MMTwA/

like image 307
Nikolas Jíša Avatar asked Dec 18 '11 11:12

Nikolas Jíša


People also ask

How is Call to undefined function mysql_connect ()?

If you get an error like Fatal error: Call to undefined function mysql_connect() when trying to install GFI HelpDesk, it probably means that MySQL support has not been enabled for PHP on your server (that is, the PHP module php-mysql has not been installed).

What does the mysql_connect () function do?

mysql_connect() establishes a connection to a MySQL server. The following defaults are assumed for missing optional parameters: server = 'localhost:3306', username = name of the user that owns the server process and password = empty password. The server parameter can also include a port number.

What is fatal error call to undefined function?

Call to undefined function error clearly shows that its not getting your function where you have defined. Reason is you are attaching full path of settings. php file with http . You need to include settings. php file without http path at the top of 'index.


1 Answers

After looking at your phpinfo() output, it appears the mysql extensions are not being loaded. I suspect you might be editing the wrong php.ini file (there might be multiple copies). Make sure you are editing the php file at C:\php\php.ini (also check to make sure there is no second copy in C:\Windows).

Also, you should check your Apache logs for errors (should be in the \logs\ directory in your Apache install.

If you haven't read the below, I would take a look at the comments section, because it seems like a lot of people experience quirks with setting this up. A few commenters offer solutions they used to get it working.

http://php.net/manual/en/install.windows.extensions.php

Another common solution seems to be to copy libmysql.dll and php_mysql.dll from c:\PHP to C:\Windows\System32.

like image 123
Bryan Avatar answered Oct 31 '22 13:10

Bryan