0

I been trying to fix this graph for some time already. Can anybody tell me what is wrong with the code or the query?

   $graphTimeOne = time(); 
   for($graphTimeOne = 29; $graphTimeOne >= 0; $graphTimeOne--){    
   $graphTimestampOne = mktime(0, 0, 0, date("n"), date("j") - $graphTimeOne, date("Y"));   
   $graphOneResult = mysql_query("SELECT COUNT(id) FROM id WHERE timestamp >= UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 29 DAY)) GROUP BY DAY(FROM_UNIXTIME(timestamp))");            
   $User = mysql_result($graphOneResult, 0, 0);     
   mysql_free_result($graphOneResult);      
   $graphBarOne[$bar_nr] = $User; // Im Array Speichern     
   $bar_title[$bar_nr] = date("Y-m-d", $graphTimestampOne);

Why is my code not working with mysql query?

user3011634
  • 13
  • 1
  • 4
  • What type of error are you getting? – Tom Hoang Oct 27 '14 at 21:52
  • at first glance `timestamp` is a reserved word, try surrounding with backticks – andrew Oct 27 '14 at 21:53
  • Please, [don't use `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php), They are no longer maintained and are [officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). Learn about [prepared statements](http://en.wikipedia.org/wiki/Prepared_statement) instead, and use [PDO](http://us1.php.net/pdo) or [MySQLi](http://us1.php.net/mysqli). [This article](http://php.net/manual/en/mysqlinfo.api.choosing.php) will help you decide. – Jay Blanchard Oct 27 '14 at 21:54

0 Answers0