Jump to content

Recommended Posts

Usually we would use

mysql_query($sql) or trigger_error(mysql_error());

 

So instead of using trigger_error() directly, could i use our own function like below?

mysql_query($sql) or showError();

function showError()
{
     trigger_error(mysql_error());
     die();
}

 

The purpose is i want to end the script if errors were  found.

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/267047-php-mysql_query-or-custom_funtion/
Share on other sites

Yes, you can, but does not make sense b/s it will show you only one error -> mysql_error().

You have to use functions to show you multiple errors, for example mysqli_connect error number or something else..


mysql_query($sql) or showError(mysqli_connect_errno());

function showError($error = null)
{
    trigger_error($error); exit;
}

 

 

 

Thanks for that jazzman1.

 

By the way, i don't really know how the "or" statement work.

 

Example:

We usually use: mysql_query($sql) or trigger_error() and so on

 

could we actually use it for our own function as well? Example

 

own_function() or trigger_error();

 

Thanks

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.