title: Write Errors to LOG file - PHP mySql
body: <p>I am using <code>mysqli</code> to handle Database operations and want to Log each and every error to a file <code>sql-error.log</code></p>
  
  <p>Code i am using is below:</p>
  
  <pre><code>$result = mysqli_query($this-&gt;_con,"CALL PROCEDURE_NAME(2)");
  if(false===$result){
    $error = 'Error calling stored procedure insert_product. Error No: ' . 
              mysqli_errno($this-&gt;_con) . ': ' . mysqli_error($this-&gt;_con);
    error_log($error . "Date::" . date("l jS \of F, Y, h:i:s A") ."\n", 3, "/sql-errors.log");
    exit();
  }
  </code></pre>
  
  <p>And on cPanel, my <code>Functions.php</code> folder structure is as below:</p>
  
  <pre><code>/public_html/site_name/sql/functions/
  </code></pre>
  
  <p>But when i execute the query then i got a below Error</p>
  
  <blockquote>
    <p>[15-Jan-2016 04:21:06 Etc/GMT] PHP Warning:  error_log(/sql-errors.log): failed to open stream: Permission denied in /public_html/site_name/sql/functions/Functions.php on line ***</p>
  </blockquote>
  
  <p>How to give permissions to write to this file and will <code>error_log</code> automatically creates file?</p>