UPDATE query with prepared operations

You are having trouble requesting an update and updating.

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; 

Compiled it and found only one link in the php documentation in the comment, but I could not understand the comment: /

0
php mysql pdo prepared-statement
source share
3 answers

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

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

Hope this helps greetings

0
source share

Do you want to

 $stmt->affected_rows(); 

against.

 $stmt->affected_rows; 

?

I'm not sure.

Otherwise, you can verify that there is no mysql error before checking the affected rows.

0
source share

The problem was that I used $ stmt-> close (); before using $ stmt-> affected_rows; stupid mistake. this is what i get for late night coding.

0
source share

All Articles