0
public function updateTodo($iSequence, $aTodo)
{
    //@TODO

    $sTodo = $aTodo['todo'];
    $stmt = $this->oConnection->prepare("UPDATE t_todolist 
        SET todo = $sTodo 
        WHERE sequence = $iSequence");

    $stmt->execute();
}

Im doing a todo list for some reason i cant update my database because my $stmt is executing false.

Mahidul Islam
  • 580
  • 11
  • 29
  • 1
    It means your request is failing: http://php.net/manual/en/pdostatement.execute.php – Jason Grim Aug 10 '18 at 03:47
  • 3
    You should be binding those variables to a prepared statement, not including them directly in the query. Try putting `$dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );` just after connecting to make sure you're getting exceptions thrown when something goes wrong, which will help you debug this problem. – Mike Aug 10 '18 at 04:07
  • 1
    I'd guess the variables are strings. Strings in SQL need to be quoted. You'd be best off using the prepared statements as intended, parameterize the values. – user3783243 Aug 10 '18 at 04:11
  • 1
    and/or dup of https://stackoverflow.com/questions/32648371/my-pdo-statement-doesnt-work – user3783243 Aug 10 '18 at 04:12

1 Answers1

1

If it returns false, then there is something wrong with your code. Make sure that you set the PDO properly. It would be better if you print the error message so that you know what the message is.

Try to put this code so that you will know what the error is

$stmt->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );