将数据从数据库返回到PHP作为变量[重复]

I'm trying to get a count of how many entries are in a database by using COUNT in SQL similar to this. This is my code, it returns/echos nothing.

$result=mysqli_query($con,"SELECT COUNT(id) as total FROM Customer");

if (!$result) echo mysql_error();

$row=mysqli_fetch_assoc($result);

echo $row['total'];

$id=$row['total'];

echo($id);

What is wrong? The connection info is correct and has no errors.

Update: I still need help with this. Please stop downvoting and not giving answers. If it's a question with an obvious answer please tell me.

Update: This is not at all a duplicate of that question. The issue was not specifically with error reporting.

Update: I answered this question and figured out my problem was with the default database which is why nothing was being returned. I can't select my answer until tomorrow.

</div>

I never put mysqli_select_db ( $con, "....."); Into my file so it never knew what database to use. I also was not getting errors because I was using mysql_error instead of mysqli_error. Once I selected the default database, it worked fine.

You are using MySQLi AND calling mysql_error(). Should be

mysqli_error($con);

Now you should see error messages, if there are any.

echo out mysqli_error($conn) instead of mysql_error()