Uncaught Error: Call to undefined function mysql_connect()
Title
Question
<span style="color: rgb(0, 0, 0); font-family: "Times New Roman"; font-size: medium;">Uncaught Error: Call to undefined function mysql_connect() in C:\xampp\htdocs\connect.php:2 Stack trace: #0 C:\xampp\htdocs\mysql.php(2): require() #1 {main} thrown in </span>C:\xampp\htdocs\connect.php<span style="color: rgb(0, 0, 0); font-family: "Times New Roman"; font-size: medium;"> on line s</span>2
so please reply for this message to correct the errors
PHP-and-MySQL MySQL-Part-2 02-03 min 50-60 sec
Answers:
Dear User,
If you are using a newer version of PHP then it should give an error. Please use mysqli function instead of mysql function.
For example:
<?php
$connect = mysqli_connect("localhost","root","") or die("Connection Failed!");
mysqli_select_db("$connect","phpacademy") or die(mysqli_error());
echo "Connected!<p>";
$connect = mysqli_connect("localhost","root","") or die("Connection Failed!");
mysqli_select_db("$connect","phpacademy") or die(mysqli_error());
echo "Connected!<p>";
?>
Login to add comment