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