Jump to content

is it my query?


Lamez

Recommended Posts

I usually only post here when I am tired and cannot find the problem, but I think I will not be able to solve this one when I am mentally sober.

 

This bit of code below is suppose to check to see if the user has added the other user as their friend, if so it will return a error message, well I do believe I tested it before, but that was before I added someone else as my friend, meaning you get the error no matter what when you have more than one friend!

 

Does anyone know why?

 

Code:

<?php
    $f_id = findInfo($user, "id");
$q = mysql_query("SELECT * FROM `friends` WHERE `a` OR `b` = '".$f_id."'");
$f = mysql_fetch_array($q);
if($f['a'] == $f_id){
  $n == 1;
}else{
  if($f['b'] == $f_id){
    $n == 1;
  }else{
    $n == 0;
  }
}
if($n == 1){
  echo "<b>".$user."</b> is your friend already";
}
?>

 

findInfo function:

<?php
function findInfo($user, $what){
  $q = mysql_query("SELECT * FROM `users` WHERE `username` = '".$user."'");
  $f = mysql_fetch_array($q);
  return $f[$what];
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.