views:

31

answers:

3

Having problems with and update query i keep getting

Warning: Crud::update() [crud.update]: Property access is not allowed yet in crud.php on line 60

This is my code

$stmt = $this->mysql->prepare('UPDATE links SET title = ?, url = ?, comment = ? WHERE id = ?');
$stmt->bind_param('sssi',$title,$url,$comment,$id);
$stmt->execute();
$stmt->close();
on line 60 return $stmt->affected_rows;

Googled it and only found one reference in the php documentation in a comment but i couldn't understand the comment :/

A: 

are you sure the stament returns true? this error occurs if the statement was not prepared properly, or not prepared at all, according to php documentation.

"To prevent this, always ensure that the return value of the "prepare" statement is true before accessing these properties."

Hope this helps cheers

RDAM
yes thats the comment i read on php.net but didnt understand it
andrei
did you tested the query by itself? i mean directly to DB? and the values you are passing to the statement are OK? i guess the documentation refers to that
RDAM
query is correct problem seems to be with return $stmt->affected_rows; very weird no idea why .
andrei
A: 

Do you want

$stmt->affected_rows();

vs.

$stmt->affected_rows;

?

I'm not sure.

Otherwise you can check to confirm that there was no mysql error first before checking the affected rows.

tandu
the problem seems to be that i closed the statement before i requested the affected_rows
andrei
A: 

The problem was that i used $stmt->close(); before using $stmt->affected_rows; silly error really. thats what i get for late night coding.

andrei