2

(Running ubuntu server 12.04)

This line in particular is giving me issues in php:

$con = mysql_connect("localhost:3306","root","root");

From turning on error reporting, I only got this returned (as it was killed at that line and nothing afterwards would print):

Fatal error: Call to undefined function mysql_connect() in /var/www/sql/login.php on line 7

I'm not sure where to go from there, as it is just killed at the line I provided. I have used just "localhost" as well, and I have successfully logged in from the command line. Could this be a php permissions issue, or something like configuration? If so, where would that be?

1
  • You don't have MySQL, but you might have MySQLi. Try mysqli_connect() instead...
    – deed02392
    Commented Oct 31, 2012 at 13:13

3 Answers 3

5

I think this happen because you don't have the mysql extension loaded on your php environment.

To fix this, in your ubuntu open the shell and type this:

sudo apt-get install php5-mysql libapache2-mod-auth-mysql

After that, just restart apache with the next command:

sudo /etc/init.d/apache2 restart

Good luck!

0
1

Your version of PHP was compiled without MySQL support. You need to recompile it, following the setup instructions for including MySQL.

0

The php_mysql library is not installed on your server. Try to take a look at the output of phpinfo() if it is really missing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.