Lamez Posted January 15, 2009 Share Posted January 15, 2009 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 More sharing options...
.josh Posted January 15, 2009 Share Posted January 15, 2009 Dunno if it's the root problem but very first thing I see wrong is you're doing $n == 1 and $n == 0 instead of one =. Link to comment https://forums.phpfreaks.com/topic/140904-is-it-my-query/#findComment-737526 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.