我遇到以下错误:
解析错误:语法错误,第7行的H:\ STUDENT \ S0213628 \ part2 \ friendslist.php中的意外T_CONSTANT_ENCAPSED_STRING
使用以下sql命令:
$sql =
"SELECT ubuser.usr_firstname, ubuser.usr_lastname, ubuser.usr_DOB,
ubuser2_1.usr_firstname & " " & ubuser2_1.usr_lastname AS UBFriend,
ubFriendsLink.ub_lnkID1, ubFriendsLink.ub_lnkID2, ubuser.usr_ID, ubuser2_1.usr_ID
FROM ubuser AS ubuser2_1 INNER JOIN (ubFriendsLink INNER JOIN ubuser
ON ubFriendsLink.ub_lnkID1 = ubuser.usr_ID) ON ubuser2_1.usr_ID =
ubFriendsLink.ub_lnkID2 WHERE (((ubFriendsLink.ub_lnkID1) = ".$_SESSION['usr_ID'] ."))
OR (((ubFriendsLink.ub_lnkID2) = ".$_SESSION['usr_ID'] ."))";
该命令旨在显示来自具有会话ID的用户以及通过friends链接表(使用ID1或ID2)链接到该用户的任何朋友的更新。
该命令似乎在访问中起作用,但是当我将sql合并到我的php页面时,该命令不起作用。
非常感谢任何帮助,谢谢。
答案 0 :(得分:0)
在& "
你关闭了你的起始报价。你需要用反斜杠来逃避它:
$sql =
"SELECT ubuser.usr_firstname, ubuser.usr_lastname, ubuser.usr_DOB,
ubuser2_1.usr_firstname & \" \" & ubuser2_1.usr_lastname AS UBFriend,
ubFriendsLink.ub_lnkID1, ubFriendsLink.ub_lnkID2, ubuser.usr_ID, ubuser2_1.usr_ID
FROM ubuser AS ubuser2_1 INNER JOIN (ubFriendsLink INNER JOIN ubuser
ON ubFriendsLink.ub_lnkID1 = ubuser.usr_ID) ON ubuser2_1.usr_ID =
ubFriendsLink.ub_lnkID2 WHERE (((ubFriendsLink.ub_lnkID1) = ".$_SESSION['usr_ID'] ."))
OR (((ubFriendsLink.ub_lnkID2) = ".$_SESSION['usr_ID'] ."))";
答案 1 :(得分:0)
双引号内的双引号导致问题。
$sql =
"SELECT ubuser.usr_firstname, ubuser.usr_lastname, ubuser.usr_DOB,
ubuser2_1.usr_firstname & \" \" & ubuser2_1.usr_lastname AS UBFriend,
ubFriendsLink.ub_lnkID1, ubFriendsLink.ub_lnkID2, ubuser.usr_ID, ubuser2_1.usr_ID
FROM ubuser AS ubuser2_1 INNER JOIN (ubFriendsLink INNER JOIN ubuser
ON ubFriendsLink.ub_lnkID1 = ubuser.usr_ID) ON ubuser2_1.usr_ID =
ubFriendsLink.ub_lnkID2 WHERE (((ubFriendsLink.ub_lnkID1) = ".$_SESSION['usr_ID'] ."))
OR (((ubFriendsLink.ub_lnkID2) = ".$_SESSION['usr_ID'] ."))