Jump to content


Photo

not checking correctly


  • Please log in to reply
3 replies to this topic

#1 aebstract

aebstract
  • Members
  • PipPipPip
  • Advanced Member
  • 1,105 posts

Posted 17 June 2006 - 08:30 PM

I have this script that should be checking to see if someone is added to the friend's list or not. I went about doing the script the way I thought it should work, though it seems to just add the user, even if they are already on the list. I wanted it to check to see if they are on, if so.. it should tell them they are, and not allow them to be added. If they are not, then it should add them:

$problem = FALSE;

$query = mysql_query("SELECT friendsid FROM friendslist WHERE userid = '$id'");
$query = mysql_fetch_array($query);         
if ($query){     
$user == $query['friendsid'];                  

} else {         

$problem = TRUE;         
$content .= 'This user is already on your Friend\'s List.<br />'; 

}   


if (!$problem) {  
 
$insert = mysql_query("INSERT INTO friendslist (userid,friendsid)".
"VALUES ('$id', '$user')") or die(mysql_error());
 
$content .= "
Added to Friend's List
";

}

There is an area of the mind that could be called unsane, beyond sanity, and yet
not insane. Think of a circle with a fine split in it. At one end there's
insanity. You go around the circle to sanity, and on the other end of the
circle, close to insanity, but not insanity, is unsanity.


#2 klaroen

klaroen
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 17 June 2006 - 08:36 PM

isn't that a wierd query their at the start??! I don't know if that as allowed..

#3 aebstract

aebstract
  • Members
  • PipPipPip
  • Advanced Member
  • 1,105 posts

Posted 17 June 2006 - 08:40 PM

ive used it in other scripts that work fine :/


edit: and for some reason that worked.

There is an area of the mind that could be called unsane, beyond sanity, and yet
not insane. Think of a circle with a fine split in it. At one end there's
insanity. You go around the circle to sanity, and on the other end of the
circle, close to insanity, but not insanity, is unsanity.


#4 klaroen

klaroen
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 17 June 2006 - 08:55 PM

oke I have some things:

- try to use the same signs: one time you use "" for your content second time ''
- You don't need to place a point ( . ) when inserting values!
example:
$query=mysql_query("INSERT into users(username,password,email) values('$RegName','$RegPass','$RegMail')");




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users