Change the value of the WHERE clause field

时间:2016-04-04 17:56:55

标签: php sql pdo

The following function works just fine, except I cannot change the book_isbn. I made separate variables for the initial ISBN(from the DB) - $initISBN and the new ISBN(from the form) - $isbn. PHP or SQL throw no error and the other fields can be modified(the function works).

function updateNote($initISBN, $title, $author, $isbn) {
    try {
      **$query = "UPDATE notes SET book_title=:title, book_author=:author, book_isbn=:isbn WHERE book_isbn=:initISBN";**
      $stmt = $this->conn->prepare($query);
      $stmt->execute(array(':initISBN'=>$initISBN, ':title'=>$title, ':author'=>$author, ':isbn'=>$isbn));
    } catch (PDOException $e) {
      die("ERROR: " . $e->getMessage());
    }
  }

Thanks for your time!

0 个答案:

没有答案