0

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.

Here's a couple of examples:

[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

I have no idea why this is happening and obviously need to sort it before the site goes live.

I can't really give any more information on this because I am clueless. I have playing around with include and include_once, 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.

Edit

The variable $ID that the notice is identifying is gotten from a mysql query and identified as such;

$ID = $row['ID'];//never echo this

Line 189 is just $ID 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.

Edit Where $ID is set.

<?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           
      }

Line 189:

WHERE E.ID = '$ID'
GROUP BY E.E_ID
ORDER BY E.timestamp DESC LIMIT 20"
14
  • Show us artist_profile.php line 189? Commented May 31, 2013 at 13:13
  • Those aren't errors. That's a notice and it's followup messages. Commented May 31, 2013 at 13:14
  • @Patrick Okay so why are they occuring? The variable is defined Commented May 31, 2013 at 13:15
  • It says it's not defined. We can't know until you show us the code. Commented May 31, 2013 at 13:20
  • 1
    @CarlosCampderrós I do want to log my errors so I can remove them Commented May 31, 2013 at 13:30

2 Answers 2

1

This is because they are just notices. Those are probably disabled in your php.ini. You can either activate by editing it or simply add in your script

error_reporting(E_ALL);
ini_set("display_errors", 1);

You might want to have a look at documentation

Sign up to request clarification or add additional context in comments.

4 Comments

@nbs189 is the error still in log rightnow? or are them from previous hours?
The notice is in the log yes. I have deleted the log several times and is still there when revisitng page. If i put echo ini_get('display_errors'); a 1 is displayed. I guess this means there is 1 error
@nbs189 did you add what i wrote at the top of artist_profile.php?
Yes I added it to the top of that and to the top of a template that is included on every page
1

Try adding this at the beginning of your file:

error_reporting(E_ALL);
ini_set("display_errors", 1);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.