0
我在下面的腳本中掃描允許查看帖子的用戶。我如何更新它,以便將查看者的ID與存儲在該字段中的人匹配。如果它匹配,那麼它不工作。存儲的條目將類似於99394david,324234smith,34343jane。所以這個腳本我沒有匹配它。如何匹配來自多個ID的一個ID?
$kit = mysql_real_escape_string($_GET['id']);
$sql="SELECT `Who_can_see` from `posts` where `post_id` = '$kit'";
$result=mysql_query($sql);
$query = mysql_query($sql) or die ("Error: ".mysql_error());
if ($result == "")
{
echo "";
}
echo "";
$rows = mysql_num_rows($result);
if($rows == 0)
{
print("");
}
elseif($rows > 0)
{
while($row = mysql_fetch_array($query))
{
$userallowed = htmlspecialchars($row['who_can_see']);
}
}
//$personid is drawn from the database. its the id of the
person viewing the link.
if ($userallowed == $personid) {
echo("allowed");
} else {
echo("not allowed");
die();
}
?>
謝謝。這沒有用。我正在使用轉義字符串,這應該夠了,不是嗎? – ariel 2012-04-26 01:06:07
@ariel是的,這就夠了。這兩個值看起來像什麼('Who_can_see'和'$ personid')完全是一個有效的例子? – jeroen 2012-04-26 01:14:26
who_can_see可能有每個人,只是我或它可以是一個人像99394david或多人喜歡99394david,324234smith,34343jane – ariel 2012-04-26 01:17:27