语法错误,PHP中出现意外的T_CONSTANT_ENCAPSED_STRING [英] Syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in PHP
本文介绍了语法错误,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端的字符串
in the above code in query string i.e string in side mysql_quey
我们遇到以下错误
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\wamp\www\samples\mysql_excel\exel_outfile.php on line 8
查询字符串'\ n'宪章中没有将其识别为字符串,这就是上述错误得到的原因
in query string '\n' charter is not identifying as string thats why above error getting
推荐答案
您需要将双引号转义为:\"
而不是""
You need to escape the double quote as: \"
instead of ""
$result=mysql_query("select * from jos_users INTO OUTFILE 'users.csv' FIELDS ESCAPED BY '\"' TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\n' ");
未转义的"
将提前终止字符串.
An un-escaped "
will prematurely terminate the string.
示例:
这是不正确的:"A " is a double quote"
这是正确的:"A \" is a double quote"
This is incorrect: "A " is a double quote"
This is correct: "A \" is a double quote"
这篇关于语法错误,PHP中出现意外的T_CONSTANT_ENCAPSED_STRING的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文