A: 

few things that come to mind...

1) try the query in phpmyadmin, what results does it return?

2) this line:

if (!$sql) die('Invalid query: ' . mysql_error());

doesn't do what you probably want it to do. it just does a boolean evaluation of the query as a string which will always return true, if the string is not empty.

3) reduce to the minimum.

4) var_dump($data)

5) var_dump($chart)

tharkun
The query works fine. Its only the Chart problem.
Ibn Saeed
A: 

The problem is, like I said in the other thread, that you've got 31 elements of data (one per day), but this code is creating one x-axis element for every 2,678,400 seconds of those 31 days:

// grid line and tick every 10
$x->set_range(
    mktime(0, 0, 0, 7, 1, date('Y')),    // <-- min == 1st
Jan, this year
    mktime(0, 0, 0, 7, 31, date('Y'))    // <-- max == 31st
Jan, this year
    );

// show ticks and grid lines for every day: 
$x->set_steps(86400);

If you get rid of those lines you'll be it'll work a lot better.

You then need to provide an array of labels for the x-axis elements, and set it using $x->set_labels_from_array($array_of_labels);

There's an example of how to do that here.

therefromhere
A: 
Ibn Saeed
delete this entry, it is not an answer and SO is not a forum. the way to do this, is to edit your question.
tharkun