Reputation: 99
I am having a bit of trouble. This was working until I added a second database class to run some test methods. After removing this I am now getting this error and can't understand why.
Warning: extract() expects parameter 1 to be array, null given in /home/bitandpi/public_html/temp/build/build.php on line 49
Here is my code:
$urltag = urldecode($contentPageVar);
$sql = "SELECT * FROM shopproducts
WHERE urltag = '$urltag' AND urltag != ''
AND pd_active > 0 AND pd_visible > 0";
$result = $database->fetch_array($sql);
echo $database->affected_row()."<BR>";
print_r($result);
exit;
if($database->affected_row() > 0) {
// run code
}
I have printed the $sql var and ran it straight into phpmyadmin query and it returns 0 results.
However if I run the above code it prints the following on my screen:
2
Array ( )
Why is it telling me it is affecting rows when it is not?
Thanks
Upvotes: 0
Views: 54
Reputation: 3643
You have use num_rows.
$urltag = urldecode($contentPageVar);
$sql = "SELECT * FROM shopproducts WHERE urltag = '$urltag' AND urltag != '' AND pd_active > 0 AND pd_visible > 0";
$result = $database->query($sql);
echo $row_cnt = $result->num_rows;
echo "<br/>";
if($row_cnt>0){
// run code
$result1 = $database->fetch_array($sql);
}
Upvotes: 1