Fatal error: Call to undefined function mysql_connect()
Fatal error: Call to undefined function mysql_connect()
This means that you are using an Updated version of PHP, which is greater than PHP version 7.x. In PHP versions 7.x and above, the function, ‘mysql_connect()‘ is depreciated and was removed.
To fix this fatal error, use the function;
‘mysqli_connect(“host”, “username”, “password”)’
You can also use the MySQL function;
‘new mysqli->(“host”,”username”,”password”,”database”)’,
which should be assigned to a $variable for reuse purposes.
CORRECT METHOD:
$mysqli = mysqli_connect(“host”, “user”, “password”, “database”);
$res = mysqli_query($mysqli, “SELECT * FROM table WHERE column LIKE ‘condition’ “);
$row = mysqli_fetch_assoc($res);
&&
$mysqli = new mysqli(“localhost”, “user”, “password”, “database”);
if ($mysqli->connect_errno) {
echo “Connection unsuccessful: . $mysqli->connect_error”;
}
$res = mysqli->query($mysqli, “SELECT * FROM table WHERE column LIKE ‘condition’ “);
$row = $res->fetch_assoc();
WRONG METHOD:
$mysql = mysql_connect(“host”, “user”, “password”);
mysql_select_db(“test”);
$res = mysql_query(“SELECT * FROM table WHERE column LIKE ‘condition’ “, $mysql);
$row = mysql_fetch_assoc($res);
Fatal error: Call to undefined function mysql_connect()
Forum [ MySQL ] | thetqweb
New Detailed, informative post on a common MySQL error!