I did already used mysqli
, the $database->query(...);
and the fetch_assoc()
function but this time, I am very confused...
My PHP is always telling me:
PHP Fatal error: Uncaught Error: Call to a member function fetch_assoc() on null in /var/www/vhosts/httpdocs/afterUpdate.php:24
This is my code:
if($database->connect_errno){
$myfile = fopen("httpdocs/wp_all_import.txt", "w");
fwrite($myfile, "+++ After Update +++\n+++Couldn't connect to database!+++\n\n");
fclose($myfile);
}
$values = $database->query("SELECT `ID` FROM `fWR6qIN_posts` where post_type = product AND post_status = publish");
$k = 0;
$count_values = mysqli_num_rows($values);
$myfile = fopen("httpdocs/wp_all_import.txt", "w");
fwrite($myfile, $count_values . "\n");
fclose($myfile);
while($row = $values->fetch_assoc()){
if($row["ID"] != null){
$k = $k + 1;
}
}
But where the hell is the error? - My other PHP file looks exactly the same it is working?
I get at mysqli_num_rows
and at fetch_assoc()
this error. But normally I should get returned 2039 IDs??
I do not get a database error! - Connection is established!
Greetings and Thank You!