Jump to content

check mysql_query result true or false


lhbdan

Recommended Posts

I have been trying to write code that deletes a book from a database if the user provides a BookName, and the corresponding DeletionCode. I then want to provide the user with feedback, telling the user whether they have deleted a book, that is they have provided a deletion code and a book name, or whether they have not deleted a book, because they have entered the wrong bookname or book ID. I thought this code would work, but it seems that the $result variable is always set as TRUE, no matter whether the code has deleted a row or not. What have i done wrong?

 

$result = mysql_query("DELETE FROM books WHERE BookName = '$_POST[bookName]' && DeletionCode = '$_POST[Deletioncode]'");

 

 

if(!$result){

die('Invalid query: ' . mysql_error());

}

else

echo "delete book";

 

Link to comment
https://forums.phpfreaks.com/topic/230559-check-mysql_query-result-true-or-false/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.