Why is mysqli_connect() an "undefined function" on my PHP server?

11,837

Solution 1

The "mysqli" extension is not loaded. You can NOT see the section in your phpinfo() file.

http://gorp.osg.ufl.edu/phptest.php

You should see something like this on that page: https://drive.google.com/open?id=0B7VdYIkRLxQWaDRLYVNLeU84am8

Just because you have uncommented the line extension=mysqli.so does not mean it will load. The file mysqli.so is possibly not in a folder where PHP is looking for it or does not exist at all.

Check "extension_dir" in your php.ini file. Then go and see if the file mysqli.so is actually there.

Have you restarted your web server?

Solution 2

Try to install PHP MySQL by:

apt-get install php5-mysql

Then your MySQL is easily set with your PHP and Apache setting. If your MySQL is installed already you can uninstall it first and then try to install PHP MySQL by the code above in a terminal.

It is the easiest way to do it without needing any settings.

Share:
11,837
Trevor
Author by

Trevor

Updated on June 04, 2022

Comments

  • Trevor
    Trevor almost 2 years

    I'm using PHP Version 5.3.3 on a Linux server. When I try to use mysql_connect() or mysqli_connect() to reach the database, I get an error saying:

    Fatal error: Call to undefined function mysql_connect()

    or

    Fatal error: Call to undefined function mysqli_connect()

    You can see my testing page here: http://gorp.osg.ufl.edu/BOT3151/testing.php

    You can see the phpinfo page here: http://gorp.osg.ufl.edu/phptest.php

    The relevant configure commands are here:

    '--with-mysql=shared,/usr' '--with-mysqli=shared,/usr/lib64/mysql/mysql_config' '--with-pdo-mysql=shared,/usr/lib64/mysql/mysql_config'

    It also says that these .ini files are being parsed:

    /etc/php.d/mysql.ini /etc/php.d/mysqli.ini

    The php.ini file also includes these lines:

    extension=mysql.so extension=mysqli.so

    So what's going wrong here? Is mySQL not properly installed on the server? How can I fix this?

    ADDENDUM: I should have explained that this is on a shared server that I don't administer. I just have access to my folder on the server through SFTP. But I do have a php.ini file and I have an extensions folder. So is this something I can fix myself or do I need help from a server administrator?