I keep getting this error when trying to execute this query.
$conn = new mysqli($servername, $username, $password, $dbname);
$query = "SELECT * FROM entry";
$result = mysql_query($query, $conn);
$count = mysql_num_rows($result);
echo $count;
I keep getting this error when trying to execute this query.
$conn = new mysqli($servername, $username, $password, $dbname);
$query = "SELECT * FROM entry";
$result = mysql_query($query, $conn);
$count = mysql_num_rows($result);
echo $count;
Since mysql_*
is deprecated so please try this:-
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$conn = mysqli_connect($server,$username,$password,$database);
$query = "SELECT * FROM entry";
$result = mysqli_query($conn,$query);
$count = mysqli_num_rows($result);
echo $count;
It is best practice not to use "mysql_query" as it is deprecated, you should try "mysqli" instead, but if you still want to use mysql and not mysqli then you should not mix both. You should try with anant kumar singh's answer.
$conn = mysqli_connect($server,$username,$password,$database);
use this...