Error creating mysqli connection

0

I'm trying to create a connection through MYSQLI plus this one giving error Fatal error: Call to undefined function mysqli_connect () in / home What can this be?

$link = mysqli_connect("localhost", "xx", "xxx", "xxx");
if (!$link) {
  echo "Error: Unable to connect to MySQL." . PHP_EOL;
  echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
  echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
  exit;
}

echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL;
echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;

mysqli_close($link);

    
asked by anonymous 11.10.2015 / 16:57

1 answer

1

The error occurs because the mysqli extension is not enabled. The phpinfo() line you should look for is MysqlI Support enabled .

Recent Linux versions of the Debian family (such as Ubuntu) have a specific command to enable PHP modules * 1 :

sudo php5enmod mysqli

and restart apache with

sudo service apache2 restart
    
19.11.2015 / 18:45