1

I know this is a very frequent question, but for the love of god i cannot find the error in my php code. The error that i'm getting is:

Parse error: syntax error, unexpected T_VARIABLE in ..\virus_scan.php on line 24

Hopefully some fresh eyes would bring a new perspective and help me identify the mistake. Line 24 is the line where the $sql variable is declared:

      if ($dbs === False)
    {
        print "can't find $database";
    }

  //--------------------------------------------------------------------------
  // 2) Query database for data
  //--------------------------------------------------------------------------

$sql = "select unix_timestamp(date(Date_Found)) * 1000 as day, count(Virus_Name) as nb from machine_virus_info where Virus_name!='NULL' group by unix_timestamp(date(Date_Found)) * 1000 ;" 
$result = mysql_query($sql) or die('SQL Error 1: ' . mysql_error());

while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
    $array[] =
        array (
            $row['day'],
            $row['nb']
            );
}
3
  • 1
    You are missing a ; at the end
    – Pekka
    Feb 26, 2013 at 16:17
  • i knew it was something simple. thanks... :D Feb 26, 2013 at 16:19
  • No prob. As long as there is no upvoted answer, you can delete the question if you want (using the "delete" link)
    – Pekka
    Feb 26, 2013 at 16:19

2 Answers 2

4

Add a semicolon after your sql declaration, i.e.

$sql = "..." ;
1

You're missing ; after the line with $sql.

Also, please make sure to update your code using the MySQLi framework as you can see here

Using the mysql_* functions are depreciated from PHP 5.5.0 on and will generate E_DEPRECATED warnings!

Not the answer you're looking for? Browse other questions tagged or ask your own question.