title: How to properly print variable to PHP error log
body: <p>I'm trying to properly print a variable to the error log so that I know if my MySQL query worked, but it doesn't print anything to my <code>errorlog.log</code> file. I set everything up below, I set errors to true and told it the file to print to but it doesn't print anything at all:</p>
  
  <pre><code>&lt;?php
  
  error_reporting(E_ALL); //to set the level of errors to log, E_ALL sets all warning, info , error
  
  ini_set("log_errors", true);
  ini_set("error_log", "/errorlog.log"); //send error log to log file specified here.
  
  include ("connection.php");
  
  $city = $_POST['city'];
  
  $state = $_POST['state'];
  
  $results = array();
  if( $query =  $db-&gt;query("SELECT business_id, BusinessName, date, post".
  "FROM WolfeboroC.posts".
  "JOIN WolfeboroC.users ON users.recid = posts.business_id".
  "WHERE city= '$city' &amp;&amp; state='$state' ".
  "ORDER BY date DESC LIMIT 0, 500") ) 
  {
    while($record = $query-&gt;fetch_assoc())
    {
  </code></pre>
  
  <p>I defined <code>$results</code>, here its a MySQL query that fetches a bunch of info from the database and returns it in $results:</p>
  
  <pre><code>    $results[] = $record;
    }
    $query-&gt;close();
  }
  
  
  echo json_encode($results);
  </code></pre>
  
  <p>This is where I try to print the variable to the error log file:</p>
  
  <pre><code>error_log(print_r($results));
  
  ?&gt;
  </code></pre>