2

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;
SergeProtector
  • 113
  • 1
  • 2
  • 6

3 Answers3

5

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;
Dharman
  • 30,962
  • 25
  • 85
  • 135
Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98
2

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.

Irshad Ali Jan
  • 203
  • 1
  • 10
1
$conn = mysqli_connect($server,$username,$password,$database);

use this...

Vivek Singh
  • 2,453
  • 1
  • 14
  • 27