0

我在运行此代码时遇到此错误。

解析错误:语法错误,第 32 行 C:\xampp\htdocs\pta\cc11205\booking.php 中的意外 '" "' (T_CONSTANT_ENCAPSED_STRING)

 $querycust = mysql_query(" SELECT * FROM customer WHERE customer_id = ".$_SESSION['customer_id']" ");

tq。

4

3 回答 3

0

逃避你的报价。

" SELECT * FROM customer WHERE customer_id = \".$_SESSION['customer_id']\" "
于 2013-05-11T19:12:12.827 回答
0

您的查询中有语法错误,请将您的查询更改为此

$querycust = mysql_query(" SELECT * FROM customer WHERE customer_id = '".$_SESSION['customer_id']."' ");
于 2013-05-11T16:58:54.027 回答
0

您在字符串中缺少连接符号。为清楚起见,我宁愿将视线存储在变量中,例如

$session_var = $_SESSION['customer_id'];
$querycust = mysql_query(" SELECT * FROM customer WHERE customer_id = $session_var");

还考虑使用PDOMySQLI扩展来防止SQL Injection.

于 2013-05-11T17:01:43.977 回答