Jump to content

Alternative To Trigger_error And Die?


son
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...