help small error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    help small error

    if ($headmod != "friends/$user_id") {
    $frends = mysql_query("SELECT * FROM `friends` WHERE `user_id` = '$user_id' AND `option`");
    $frends = mysql_fetch_array($frends);
    $new_frends = mysql_result(mysql_query("SELECT COUNT(*) FROM `friends` WHERE `user_id` = '$user_id' AND `option`IN(1, 2)"), 0);
    if ($new_frends) $list[] = '<a href="' . $set['homeurl'] . '/users/friends.php?act=new' . ($frends['option'] == '2' ? '&amp;mod=delete' : '') . '">add</a> (+ ' . $new_frends . ')';
    }

    on profile i have
    PHP Code:
    $friends mysql_result(mysql_query("SELECT COUNT(*) FROM `friends` WHERE `friends`='1' AND (`friend_id`='" $user['id'] . "' AND `user_id`='$user_id') OR (`friend_id`='$user_id' AND `user_id`='" $user['id'] . "')"), 0);
        if (
    $friends){
        echo 
    '<a href="friends.php?act=add&amp;user=' $user['id'] . '">Add Friend</a>';
        }
        else {
        echo 
    '<a href="friends.php?act=del&amp;user=' $user['id'] . '">Delete Friend</a>';
        } 
    now ive tried 1 2 and 3 in the value where it is selected on the dbase but on profiles it says delete instead of add any input will be appreciated as making something new
    Last edited by ozziemale31; 01.04.12, 09:00.









    Dont Ask Me Dumb Questions.Or you'l get a Dumb Answer..
    Want A Profesional Logo or Theme For Your wap site Pm Me.If I Have The Time Ill Make It For Free


    #2
    I would advise on using mysql_num_rows() instead of mysql_result() because if it returns no rows then it will cause a silent error (you will see it when php error messages are turned on)

    Added after 3 minutes:

    also you might have to rearrange your ANDs/ORs to something like this:
    PHP Code:
    "SELECT COUNT(*) FROM `friends` WHERE (`friends`='1' AND `friend_id`='" $user['id'] . "' AND `user_id`='$user_id') OR (`friends`='1' AND `friend_id`='$user_id' AND `user_id`='" $user['id'] . "')"

    ////blah some text here to fix bug with opera and this forum :/ 
    (moving the `friends`='1' AND to include in both of the OR statements)
    Last edited by something else; 01.04.12, 12:18.

    Comment


      #3
      hmmm, try this bro.

      PHP Code:
      if ($headmod != "friends/$user_id") {
       
      $frends mysql_query("SELECT * FROM `friends` WHERE `user_id` = '$user_id' AND `option`");
       while (
      $frends mysql_fetch_array($frends)) {
       
      $new_frends mysql_result(mysql_query("SELECT COUNT(*) FROM `friends` WHERE `user_id` = '$user_id' AND `option`IN(1, 2)"), 0);
       if (
      $new_frends$list[] = '<a href="' $set['homeurl'] . '/users/friends.php?act=new' . ($frends['option'] == '2' '&amp;mod=delete' '') . '">add</a> (+ ' $new_frends ')';
       }

      <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

      Comment


        #4
        Originally posted by arnage View Post
        hmmm, try this bro.

        PHP Code:
        if ($headmod != "friends/$user_id") {
         
        $frends mysql_query("SELECT * FROM `friends` WHERE `user_id` = '$user_id' AND `option`");
         while (
        $frends mysql_fetch_array($frends)) {
         
        $new_frends mysql_result(mysql_query("SELECT COUNT(*) FROM `friends` WHERE `user_id` = '$user_id' AND `option`IN(1, 2)"), 0);
         if (
        $new_frends$list[] = '<a href="' $set['homeurl'] . '/users/friends.php?act=new' . ($frends['option'] == '2' '&amp;mod=delete' '') . '">add</a> (+ ' $new_frends ')';
         }

        its ok i got it working after doing some php manual referance









        Dont Ask Me Dumb Questions.Or you'l get a Dumb Answer..
        Want A Profesional Logo or Theme For Your wap site Pm Me.If I Have The Time Ill Make It For Free

        Comment

        Working...
        X