Debugging issues, and graphs not showing up.
See Chapter 9, page 241, figure 9-1. There are graphs
for daily and monthly traffic.
If these graphs do not come out, it may be your
debugging statements.
If you are debugging by using print statements to
the browser, such as print "got this value on this line<BR>",
then your graphs might not come out.
The following line is where this issue starts.
It is in the file report.php, shown on page 260, 7 lines up
from the bottom.
Code:
<p><img src="img/chart.php?month" alt="monthly traffic distribution"></p>
It seems like any output to the browser in the chart.php file or BarChart.php
file is part of the image. It seems like you only want to
write the png image in there and nothing else. If you put a
statement like print "I am in this function" in one of these
files, then your graph will not come out.
You need to be careful that you don't have these debugging
statements in any of the included files as well.
You can always write your messages to the php error log instead
and that is sufficient for tracking.
I have a function I use for debugging that prints to the
php error log and also prints to the browser. I will
change it to have a flag so I can turn off printing to
the browser when needed.
That is all you need to know to get around this problem.
I will share with you my troubleshooting experience.
One of my approaches was to get something in chart.php that works
and build it back up until it breaks. To do this,
I replaced src=img/chart.php with a copy of captcha.php
(src=img/captchacopy.php) and that worked.
I modified captchacopy.php to just draw a simple rectangle, that worked.
Then I modified chart.php by replacing the calls to the BarChart
functions with this simple drawing of a rectangle.
It did not work.
I tried eliminating code out of chart.php until it would
work. It turns out I had eliminated everything else but the include
files. It still did not work. At this point I had to take a
close look at the include files. In db.php I have calls to the
debug function. I temporarily commented these out and it started to work,
so something in my debug function was causing the problem. It turns out
the print statement in the debug function was the problem. I
commented it out and it started working. I then
built chart back up to it's original form and it worked
The charts and graphs worked for me,
after I fixed this problem, and the MySQL version problem I talked
about in the post "Chap 9 - problems using MySQL versions prior to version 5.".
I hope this helps anyone else who had trouble seeing the charts.
MY CONFIGURATION.
I am using the Wrox download code.
I am using browser Firefox 3.0.19
Unix: freeBSD