使用sql:语法错误删除联系人列表中的后续关系?

问题描述:

我试图删除我的数据库中的关系。我想用一个查询执行一个代码,删除我所关注的一个,也是相反的方向。我有下面的代码,有一个语法错误:使用sql:语法错误删除联系人列表中的后续关系?

//profileId is the current user and contactsProfileId which user he/she follows 
$sql = " 
DELETE FROM contactlists 
WHERE (profileId = '$profileId AND contactsProfileId = '$contactsProfileId') 
OR (profileId = '$contactsProfileId' AND contactsProfileId = '$profileId') 
"; 

你忘了添加关闭'单引号的$profileId

试试这个

$sql = " 
DELETE FROM contactlists 
WHERE (profileId = '$profileId' AND contactsProfileId = '$contactsProfileId') 
OR (profileId = '$contactsProfileId' AND contactsProfileId = '$profileId') 
"; 
+0

确定是有点盲目那里;) – einstein 2011-04-20 10:57:10

看看第一$profileId

//profileId is the current user and contactsProfileId which user he/she follows 
$sql = " 
DELETE FROM contactlists 
WHERE (profileId = '$profileId' AND contactsProfileId = '$contactsProfileId') 
OR (profileId = '$contactsProfileId' AND contactsProfileId = '$profileId') 
"