title: Apache error log shows PHP errors but no errors outputted by PHP
body: <p>I have just had a look at the apache error log and the file is huge! There have been no errors on the site itself and none are outputted by PHP but in the error log there are many undefined variables etc.</p>
  
  <p>Here's a couple of examples:</p>
  
  <pre><code>[Fri May 31 14:04:15 2013] [error] [client 127.0.0.1] PHP Notice:  Undefined variable: ID in C:\\wamp\\www\\artist_profile.php on line 189, referer: http://localhost/Discover
  
  [Fri May 31 14:04:15 2013] [error] [client 127.0.0.1] PHP Stack trace:, referer: http://localhost/Discover
  
  [Fri May 31 14:04:15 2013] [error] [client 127.0.0.1] PHP   1. {main}() C:\\wamp\\www\\artist_profile.php:0, referer: http://localhost/Discover
  </code></pre>
  
  <p>I have no idea why this is happening and obviously need to sort it before the site goes live.</p>
  
  <p>I can't really give any more information on this because I am clueless. I have playing around with <code>include</code> and <code>include_once</code>, swapping them around but this had no effect. My only other thought is that the site use a history API script to fetch pages through ajax without a full refresh. Maybe because only part of the new page is loaded in errors are being logged. But I don't see why they would be logged in apache and not outputted into the browser.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>The variable <code>$ID</code> that the notice is identifying is gotten from a mysql query and identified as such; </p>
  
  <pre><code>$ID = $row['ID'];//never echo this
  </code></pre>
  
  <p>Line 189 is just <code>$ID</code> inside another query. I can echo out $ID anywhere on the page and no error will be displayed. By the way the comment is there to remind anyone not to echo it out for security reasons.</p>
  
  <p>Edit
  Where <code>$ID</code> is set.</p>
  
  <pre><code>&lt;?php require("includes/database.php"); 
         $url = $_SERVER["REQUEST_URI"]; //get url for db
         $url = substr($url, 1);
         $result = mysql_query ("SELECT * ,
                                (SELECT COUNT(*) FROM artist_follows WHERE follows_ID = A.ID) AS followers,
                                (SELECT COUNT(*) FROM artist_follows WHERE ID = A.ID) AS following,
                                (SELECT COUNT(*) FROM tracks WHERE ID = A.ID) AS tracks
                                FROM artists A WHERE url = '$url' LIMIT 1");
         $count = mysql_num_rows($result);
         if ($count === 0){
         //redirect to 404
         header ("location:404");
         }
         while($row = mysql_fetch_array($result)){
            $ID = $row['ID'];//never echo this           
        }
  </code></pre>
  
  <p>Line 189: </p>
  
  <pre><code>WHERE E.ID = '$ID'
  GROUP BY E.E_ID
  ORDER BY E.timestamp DESC LIMIT 20"
  </code></pre>