$conn = mysql_connect($dbhost, $dbuser, $dbpass);

PROBLEM: Fatal error: Uncaught Error: Call to undefined function mysql_connect().

Probably the problem is that mysql_connect() function is not supported in PHP 7.

There are two alternatives: MySQLi and PDO.

MySQLi database connection


<?php
$servername 
"localhost";
$username "your username";
$password "your password";
$database "databasename";
// Create connection

$conn mysqli_connect($servername$username$password$database);

// Check connection

if ($conn->connect_error) {
die(
"Connection failed: " $conn->connect_error);
}

echo 
"Database successfully connected";

mysqli_close($conn);

?>


PDO Connect (open, select) a MySql Database








Privacy Policy