title: PHP mysql error_log and immediately return a value
body: <p>I'm writing a function that queries my database, and if the mysql query errors out for some reason, I'd like my function to return a value (in this case -1) indicating query failure, rather than dying out of the whole script.</p>
  
  <p>Usually I just use this construct:</p>
  
  <p><code>$result  = mysql_query($sql) or die( [some error information] );</code></p>
  
  <p>But in this case I don't want to die, but I do need to break out of the function and have some way to tell the calling function that something went wrong, while still being able to manually check the logs for the source of the error. Is there a way to do this? The semi-pseudocode would look something like:</p>
  
  <pre><code>$result = mysql_query($sql) or {
      error_log( [some error information] );
      return -1;
  }
  </code></pre>
  
  <p>But I've tried a couple variations on that and (as one might expect) they don't work.</p>
  
  <p>Any suggestions? Thanks.</p>