<?$conn=mysql_connect("localhost","root","123456","gb2312");
if(mysql_connect_erron()!=0)
{
$erron = mysql_connect_errno();
$errmsg = mysql_connect_error();
echo "数据库连接错误;($errno) $errmsg<br/>\n";
exit;
}
$conn->query("SET NAMES 'gb2312'");
$query_str = "SELECT * FROM text";
$result = @$conn->query($query_str);
if($result === FALSE)
{
echo "SQL语言为执行成功!";
$conn->close();
exit;
}
else
{
echo <<<EOM
<table>
<tr>
<td>ID</td>
<td>NAME</td>
</tr>
EOM; while(($row_data = @$result->fetch_assoc()) !==NULL)
{
echo <<<EOM
<tr>
<td>{$row_data['id']}</td>
<td>{$row_data['name']}</td>
</tr>
EOM;
}
echo <<<EOTABLE
</table>
EOTABLE;
$result->close();
}
$conn->close();
}?>是不是 这些 是引起错误的主要原因,我在书上说这是heredoc表示法,求错。。

解决方案 »

  1.   

    现实错误如下:
                Parse error: syntax error, unexpected T_SL in C:\AppServ\www\lianxi\changshi.php on line 22
      

  2.   

    用 $array(0) 或者  $id
      

  3.   

    EOM 后面有空格吗。如果有,去掉。 试试看
      

  4.   

    三个<<<是连在一起的,好像被你拆开吧