Jump to content

Alternative To Trigger_error And Die?


son

Recommended Posts

I run a query and as I will put it live shortly want only to output a customer-friendly message with all the content below that there normally is. 'mysql_query o trigger_error will show error message, so this is a no no. Alternatively 'mysql_query or die' won't display the bottom content. What is best to do?Son

Link to comment
Share on other sites

The resource contained in the result variable will resolve to false if the query fails, so you just have to check that.

$result = mysql_query($some_query);if ($result) {	do_something();} else {	echo "Oh no, we seem to be having a problem.";}continue_with_rest_of_page();

Link to comment
Share on other sites

The resource contained in the result variable will resolve to false if the query fails, so you just have to check that.
$result = mysql_query($some_query);if ($result) {	do_something();} else {	echo "Oh no, we seem to be having a problem.";}continue_with_rest_of_page();

Great! This is working well;-)Son
Link to comment
Share on other sites

Archived

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

×
×
  • Create New...