이 mysql 쿼리에서 원하는 결과를 얻는데 문제가 있습니다. 그리고 문제는이 코드 줄에 있다고 생각합니다 :빈 결과를 얻지 않고이 mysql 쿼리를 어떻게 작동시킬 수 있습니까?
$ group = "mybb_users에서 SELECT * usergroup 및 additionalgroups = '$ usergroup'";
데이터베이스의 additionalgroups 열에 둘 이상의 값이 쉼표 (,)로 구분되어 있기 때문에 usergroup에 하나의 값만있는 것으로 나타났습니다. 여기
이미지입니다 : 여기에 스크린 샷입니다 http://i.imgur.com/UTbmX.jpg
내가 코드에서 additionalgroups 열을 제거하고 오직 사용자 그룹 열을 확인하지만 내가 아래 :(원하는없는 경우 전체 코드가 완벽하게 작동 전체 코드입니다. 확인하는 방법에
// Connect to server and select databse.
mysql_connect("$db_host", "$db_user", "$db_pass")or die("cannot connect to mysql");
mysql_select_db("$db_name")or die("cannot select DB");
$id=$_GET['lid']; // Get lid from URL
$usergroup =$_GET['game']; // Get the usergroup/game from the URL
// Check to see if the user is a VIP Member and fetch them.
$group="SELECT * from mybb_users where usergroup AND additionalgroups = '$usergroup'";
$group2=mysql_query($group) or die("Could not get users");
while($raw=mysql_fetch_array($group2))
{
// Fetch all UserIDs of the VIP members and match them with the UfID (in the userfields table)
$userid = $raw['uid'];
$group3="SELECT * from mybb_userfields where ufid = '$userid'";
$group4=mysql_query($group3) or die("Could not match userid");
while($raw=mysql_fetch_array($group4))
{
// assigns a lid from the vip members to the variable $lid
$lid = $raw['fid7'];
// Display the hash of the lid if it matches with the lid from the URL
if($lid == '')
{
}
elseif($lid == $id)
{
echo "[key]{$lid};";
}
else
{
}
}
}
'$ usergroup'은 사용자가 제공 한 입력에서 직접 가져 오지만 위생적으로 처리하지는 않습니다. 입력 내용을 삭제하십시오. http://php.net/manual/en/function.mysql-real-escape-string.php –