我在运行此代码时遇到此错误。
解析错误:语法错误,第 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。
逃避你的报价。
" SELECT * FROM customer WHERE customer_id = \".$_SESSION['customer_id']\" "
您的查询中有语法错误,请将您的查询更改为此
$querycust = mysql_query(" SELECT * FROM customer WHERE customer_id = '".$_SESSION['customer_id']."' ");
您在字符串中缺少连接符号。为清楚起见,我宁愿将视线存储在变量中,例如
$session_var = $_SESSION['customer_id'];
$querycust = mysql_query(" SELECT * FROM customer WHERE customer_id = $session_var");
还考虑使用PDO
或MySQLI
扩展来防止SQL Injection
.