2013-02-26 217 views
1

我知道這是一個非常常見的問題,但對於上帝的愛我無法在我的php代碼中找到錯誤。那我得到的錯誤是:php/mySQL - 解析錯誤:語法錯誤,意外的T_VARIABLE錯誤

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

希望一些新鮮的眼睛會帶來一個全新的視角,幫我鑑定的錯誤。 第24行是在$ SQL變量聲明行:

 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'] 
      ); 
} 
+1

你錯過了';'在末尾 – 2013-02-26 16:17:39

+0

我知道這很簡單。謝謝...:D – sSmacKk 2013-02-26 16:19:14

+0

沒有問題。只要沒有問題解答,您可以刪除問題(使用「刪除」鏈接) – 2013-02-26 16:19:39

回答

4

添加一個分號您的SQL聲明之後,即

$sql = "..." ; 
1

你跟$sql行後失蹤;

此外,請務必使用MySQLi的框架來更新你的代碼,你可以看到here

使用mysql_*職能從PHP 5.5.0上的貶值,會產生E_DEPRECATED警告!

相關問題