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
https://forums.phpfreaks.com/topic/140904-is-it-my-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.