语法错误,PHP 中出现意外的 T_CONSTANT_ENCAPSED_STRING
mysql_connect("localhost","root","");
mysql_select_db("hitnrunf_db");
$result=mysql_query("select * from jos_users INTO OUTFILE 'users.csv' FIELDS ESCAPED BY '""' TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n' ");
header("Content-type: text/plain");
header("Content-Disposition: attachment; filename=your_desired_name.xls");
header("Content-Transfer-Encoding: binary");
header("Pragma: no-cache");
header("Expires: 0");
print "$header\n$data";
在上面的代码中,在查询字符串(即 mysql_quey 中的字符串)中,
我们在查询字符串 '\n' 中收到以下错误,
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\wamp\www\samples\mysql_excel\exel_outfile.php on line 8
宪章未识别为字符串,这就是上面错误的原因
mysql_connect("localhost","root","");
mysql_select_db("hitnrunf_db");
$result=mysql_query("select * from jos_users INTO OUTFILE 'users.csv' FIELDS ESCAPED BY '""' TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n' ");
header("Content-type: text/plain");
header("Content-Disposition: attachment; filename=your_desired_name.xls");
header("Content-Transfer-Encoding: binary");
header("Pragma: no-cache");
header("Expires: 0");
print "$header\n$data";
in the above code in query string i.e string in side mysql_quey
we are getting following error
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\wamp\www\samples\mysql_excel\exel_outfile.php on line 8
in query string '\n' charter is not identifying as string thats why above error getting
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将双引号转义为:
\"
而不是""
未转义的
"
将过早终止字符串。示例:
以下错误:
"A " is a double quote"
这是正确的:
“A \”是双引号”
You need to escape the double quote as:
\"
instead of""
An un-escaped
"
will prematurely terminate the string.Example:
This is incorrect:
"A " is a double quote"
This is correct:
"A \" is a double quote"