I am slowly converting some PHP 5.6.x scripts over to PHP 7.3 and I’ve been running into a wall with getting the code below to work. If I run the query in phpMyAdmin, it returns 88 records - which is the correct number. However, when I run the code below, it either returns a number of 45 records, or “Array”, or blank.
Can anyone point out what I’m doing wrong with suggestions?
// 1. Create a database connection
$connection = mysqli_connect(“localhost”,“USERNAME”,“PASSWORD”);
if (!$connection) {
die(“Database connection failed”);
}
// 2. Select a database to use
$db_select = mysqli_select_db($connection, “DATABASE-NAME”);
if (!$db_select) {
die("Database selection failed: " . mysqli_error($connection));
}
$ct_2004_destroyed = mysqli_query($connection, “SELECT COUNT(*) as count_2004_destroyed FROM registry_xlr
WHERE model_year
= ‘2004’ AND status
= ‘Destroyed’”);
$count_2004_destroyed = mysqli_fetch_array($ct_2004_destroyed);
Output: