2014-07-28 21:34
浏览 75


What's wrong with my below lines of SQL statement in PHP which causes syntax/parse error. Very simple question but I really appreciate your answers.

$sql = "SELECT * FROM my_table WHERE column1 = '$_POST["my_value"]'";

following is the error: "Parse error: syntax error, unexpected '"', expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)". I changed the code according to the error(changed " to ' in $_POST or removed it for example) but again received errors. Thanks in advance for the help.

图片转代码服务由CSDN问答提供 功能建议

PHP下面的SQL语句行导致语法/解析错误有什么问题。 非常简单的问题,但我非常感谢你的回答。</ p>

  $ sql =“SELECT * FROM my_table WHERE column1 ='$ _POST [”my_value“]'”; 
 </ 代码> </ pre> 

以下是错误: “解析错误:语法错误,意外”“,期望标识符(T_STRING)或变量(T_VARIABLE)或数字(T_NUM_STRING)”。I 根据错误更改了代码(例如在$ _POST中更改为'或删除它)但又一次收到错误。 在此先感谢您的帮助。</ p> </ div>

1条回答 默认 最新

相关推荐 更多相似问题