这是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
答案 0 :(得分:1)
在双引号内使用数组索引变量时,应将变量放在{}中。所以请改用{$ _SESSION ['login_user']}。
答案 1 :(得分:0)
使用以下查询
"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";
答案 2 :(得分:0)
在双引号字符串中,您需要使用大括号进行数组访问。 试试这个
{$_SESSION['login_user']}