[英]Parse error in mysql query
這是mysql查詢:
$data = "SELECT course_name, studentAttendance.course_course_code
FROM login, course, staff, studentAttendance
WHERE studentAttendance.staff_staff_id = staff.staff_id
AND studentAttendance.course_course_code = course.course_code
AND staff.login_login_id = login.login_id
AND login.login_id = $_SESSION['login_user']
GROUP BY studentAttendance.course_course_code";
該錯誤據說是:
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE),
expecting identifier (T_STRING) or variable (T_VARIABLE) or number
(T_NUM_STRING) in C:\wamp\www\attendance_system\dashboard-lecturer.php on line 267
在雙引號內使用數組索引變量時,應將變量放在{}內。 因此,請改用{$ _SESSION ['login_user']}。
使用以下查詢,
"SELECT course_name, studentAttendance.course_course_code FROM login, course, staff, studentAttendance
WHERE studentAttendance.staff_staff_id = staff.staff_id
AND studentAttendance.course_course_code = course.course_code
AND staff.login_login_id = login.login_id
AND login.login_id = '".$_SESSION['login_user']."'
GROUP BY studentAttendance.course_course_code";
您需要大括號以雙引號字符串訪問數組。 嘗試這個
{$_SESSION['login_user']}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.