ohdang888 Posted March 5, 2008 Share Posted March 5, 2008 Okay, so i want this script to write the "id of the new friend" in the first column of the table that has "0" has the value in it. right now, its overwriting the info in column 1, despite the fact that column 1 had a "1" in it (not a "0") the problem is probably near the bottom of the script <?php if($action == 'accept'){ $result = mysql_query("SELECT `{$field}` FROM `friend_requests` WHERE `id`='{$id}'") or die(mysql_error()); $new_friends = mysql_fetch_array($result); $new_friend_id = $new_friends[$field]; $y = 1;// used for getting info from the right column $empty = 1; $result = mysql_query("SELECT * FROM `user_friends` WHERE `id`='{$id}'") or die(mysql_error()); $friends = mysql_fetch_array($result); if($friend['1'] != 0){ $empty++; $y++; if($friend['2'] != 0){ $empty++; $y++; if($friend['3'] != 0){ $empty++; $y++; if($friend['4'] != 0){ $empty++; $y++; if($friend['5'] != 0){ $empty++; $y++; } } } } } mysql_query("UPDATE `user_friends` SET `{$empty}` = '{$new_friend_id}' WHERE `id`='{$id}' ") or die(mysql_error()); mysql_query("UPDATE `friend_requests` SET `{$field}` = '0' WHERE `id`='{$id}' ") or die(mysql_error()); echo'Friend Successfully Added!<br>'; echo 'Check out their profile <a href="../profile.php?id='; echo $new_friend_id; echo '">here</a>'; } ?> Quote Link to comment Share on other sites More sharing options...
peranha Posted March 5, 2008 Share Posted March 5, 2008 You are defining friends here $friends = mysql_fetch_array($result); and using friend without the s in the rest of the script. if($friends['1'] != 0){ $empty++; $y++; if($friends['2'] != 0){ $empty++; $y++; if($friends['3'] != 0){ $empty++; $y++; if($friends['4'] != 0){ $empty++; $y++; if($friends['5'] != 0){ $empty++; $y++; } } } } } Quote Link to comment Share on other sites More sharing options...
ohdang888 Posted March 5, 2008 Author Share Posted March 5, 2008 wow. what a stupid mistake. Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.