i have the following query:
$timecheck = $db->query("SELECT (B <= NOW()) AS var FROM table1 WHERE x='$x'");
while ($row = $db->fetch_object()){
if ($row->var != 0){
$updatestatus = $db->query("UPDATE table2 SET abc='1' WHERE x='$x'");
}
}
and get the following errormessage:
Fatal error: Call to undefined method mysqli::fetch_object()
that relates to this line:
while ($row = $db->fetch_object()){
i also was trying to use:
while ($row = $db->fetch_object($timecheck)){
without any success. So in the manual is nothing written about how to use an alias by fetch-method.
it would be great if there is someone who could tell me what am i doing wrong. thanks a lot.
Try this
Mysqli::query
does not have fetch_object
method it would return mysqli_result::fetch_assoc
for more information please look at
http://www.php.net/manual/en/mysqli.query.php
http://php.net/manual/en/mysqli-result.fetch-assoc.php
http://www.php.net/manual/en/mysqli-result.fetch-object.php
Example :
$result = $db->query ( "SELECT (B <= NOW()) AS var FROM table1 WHERE x='$x'" );
while ( $row = $result->fetch_object () ) {
if ($row->var != 0) {
$updatestatus = $db->query ( "UPDATE table2 SET abc='1' WHERE x='$x'" );
}
}
Thanks
:)