错误获取数组

时间:2013-04-16 08:28:06

标签: php html mysql fetch

我尝试使用mysql_fetch_array使用此代码

获取我的所有数据
while($row = mysql_fetch_array($sql)){
    if($row_counter % 2){
        $row_color="bgcolor='#FFFFFF'";
    }else{
        $row_color="bgcolor='#F3F6F8'";
    }
    echo "<tr class=\"TrColor\" ".$row_color.">";
    echo "<td>" . $row['wipo_applicant1_city'] . "</td>\n";
    echo "<td>" . $row['applicant1_addr1'] . "</td>\n";
    echo "<td>" . $row['wipo_applicant1_state'] . "</td>\n"; 
    echo "<td>$" . $row['invention-title'] . "</td>\n";  
    echo "</tr>";
    $row_counter++;
}

但我收到了错误

syntax error, unexpected T_WHILE, expecting ',' or ';' 

在这一行

while($row = mysql_fetch_array($sql)){
谁知道那条线有什么问题?

2 个答案:

答案 0 :(得分:2)

听起来你错过了那之前的;,

答案 1 :(得分:2)

while循环之前的行末尾没有分号;

echo 'Whatever' //<--- You must be missing a semi-colon here
while($row = mysql_fetch_array($sql)){ //<----- So not exactly this line, but the line before