Rumah >pembangunan bahagian belakang >tutorial php >连接mysql时unexpected T_ENCAPSED_AND_WHITESPACE错误
$m_dblink=mysql_connect("xxx","user","passwore",true)or die('Could not connect database in host');
mysql_select_db("check",$m_dblink) or die('Could not select database');
mysql_query("SET NAMES UTF8",$m_dblink);
$query="SELECT a.qa,a.svn_url,a.notifylist,b.tablename,b.file,b.level,b.description FROM result as b,svnurl_check_list AS a WHERE a.line=\"search\" and a.line = b.line
and b.result=\"fail\";
echo $query,PHP_EOL;
$result = mysql_query($query,$m_dblink) or die('uery failed:' );
$count = mysql_num_rows($result);
for($index=0; $index $row = mysql_fetch_array($result, MYSQL_ASSOC);
//$tablename= $row['tablename'];//这就是出错的那行
print_r($row);
//echo " tablename:$tablename";
}
mysql_free_result($result);
mysql_close($m_dblink);
报了下面的错误:
PHP Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in line 36
但出错的那行是注释掉了的呀
原因到底在哪里呢
$query="SELECT a.qa,a.svn_url,a.notifylist,b.tablename,b.file,b.level,b.description FROM result as b,svnurl_check_list AS a WHERE a.line=\"search\" and a.line = b.line
and b.result=\"fail\"";
问题在这里
$query="SELECT a.qa,a.svn_url,a.notifylist,b.tablename,b.file,b.level,b.description FROM result as b,svnurl_check_list AS a WHERE a.line=\"search\" and a.line = b.line
and b.result= \"fail\";
应写作
$query="SELECT a.qa,a.svn_url,a.notifylist,b.tablename,b.file,b.level,b.description FROM result as b,svnurl_check_list AS a WHERE a.line=\"search\" and a.line = b.line
and b.result= 'fail'";