That's an easy fix: look closely at your first line:
mysqli_connect();
The mysqli_*
extension is used, as it should be, but you then procede to call all sorts of deprecated mysql_*
functions. Just change those calls to the more contemporary, and non-deprecated mysqli_*
counterparts.
Other problems include your calling mysqli_close
too soon (after you close the connection, you still try to work with the DB results).
And you're not even calling mysqli_close
correctly: that function requires you to pass the db connection as an argument:
mysqli_close($connection);
Spend some time reading the manual
On your other problems: the query uses a reserved keyword: table
, in MySQL, that should be escaped:
$result = mysqli_query(
$connection,//pass mysqli connection as first param
'SELECT * FROM `table`'
);
if (!$result)
exit('Query failed');//ALWAYS CHECK RETURN VALUES!!
$count = mysqli_num_rows($result);
//and so on