Re: mysql_query returning empty result after DELETE
| From: | Chris | Date: | Sun, 13 Sep 2009 22:40:37 +0000 |
| Subject: | Re: mysql_query returning empty result after DELETE | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-46496@lists.php.net to get a copy of this message | ||
Stan wrote:
I did a "DELETE FROM picture" where "picture" is a table in my database.Because this deletes all your records - so doing a select afterwards will find nothing.
Afterward, this piece of code does not generate an error
----------------------------------------------
try
{
$query = "SELECT * FROM picture p " .
"WHERE p.pictureFile='" . $pictureFile . "'";
$thisRow =
mysql_query($query, $pictures_connection);
}
catch(Exception $e)
{
echo 'caught exception: ', $e->getMessage()."\n";
$result = False;
}
an empty result set is fine - it means no records found. It will not generate an exception.
I'm not sure when mysql will generate an exception either, mysql_query returns FALSE if the query fails (see http://www.php.net/mysql_query). You then have to use mysql_error to get the reason why it failed.
--
Postgresql & php tutorials
http://www.designmagick.com/