quickstopman Posted January 19, 2008 Share Posted January 19, 2008 can someone explain to me why this doesn't retrieve any names all it prints out are <br />'s <?php $friends = mysql_query("SELECT * FROM friends WHERE friends_with = '{$_SESSION['id']}' AND friend = '{$_SESSION['id']}' AND accepted = 'yes'") or die(mysql_error()); $sql1 = mysql_fetch_array($friends); while ($sql1 = $sql2) { $friend = mysql_query("SELECT * FROM users WHERE id = '{$sql2['friends_with']}'") or die(mysql_error()); $friend_stuff = mysql_fetch_array($friend); echo $friend_stuff['username'] ."<br />"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/86798-not-retrieving-info/ Share on other sites More sharing options...
p2grace Posted January 19, 2008 Share Posted January 19, 2008 Where's $sql2 coming from in your where statement? Quote Link to comment https://forums.phpfreaks.com/topic/86798-not-retrieving-info/#findComment-443654 Share on other sites More sharing options...
AndyB Posted January 19, 2008 Share Posted January 19, 2008 can someone explain to me why this doesn't retrieve any names all it prints out are new lines I'm amazed it does anything other than print error messages. http://www.tizag.com/mysqlTutorial/mysqlfetcharray.php will point you in the right direction Quote Link to comment https://forums.phpfreaks.com/topic/86798-not-retrieving-info/#findComment-443656 Share on other sites More sharing options...
quickstopman Posted January 19, 2008 Author Share Posted January 19, 2008 GAHH im so stupid i can't believe i forgot how to do that!!!!!! thanks ;D Quote Link to comment https://forums.phpfreaks.com/topic/86798-not-retrieving-info/#findComment-443661 Share on other sites More sharing options...
quickstopman Posted January 19, 2008 Author Share Posted January 19, 2008 ok i fixed that put still no information is being printed its just <pre><br /></pre>'s heres the whole entire page of code.... <?php include("file_type.php"); if ($_SESSION['username'] == '') { header("location:http://www.socialgrabbr.com/login.php"); } $friends = mysql_query("SELECT * FROM friends WHERE friends_with = '{$_SESSION['id']}' AND friend = '{$_SESSION['id']}' AND accepted = 'yes'") or die(mysql_error()); while ($sql1 = mysql_fetch_array($friends)) { $friend = mysql_query("SELECT * FROM users WHERE id = '{$sql1['friends_with']}'") or die(mysql_error()); $friend_stuff = mysql_fetch_array($friend); echo $friend_stuff['username'] ."<br />"; echo $sql1['id']; } if (isset($_GET['type']) && $_GET['type'] == 'request') { if (isset($_GET['request_id'])) { $sql = mysql_query("SELECT * FROM users WHERE id = '{$_GET['request_id']}'") or die(mysql_error()); $req_user = mysql_fetch_array($sql); if (!$req_user['username'] == '') { $check = mysql_query("SELECT * FROM `friends` WHERE `friend` = '{$req_user['id']}' AND `friends_with` = '{$_SESSION['id']}' ") or die(mysql_error()); $c = mysql_num_rows($check); if (!$c > 0) { $submit = $_POST['submit']; if ($submit) { $query = mysql_query("INSERT INTO `friends` (`friend`, `friends_with`) VALUES ('{$req_user['id']}', '{$_SESSION['id']}')") or die(mysql_error()); echo "You have successfully added {$req_user['username']} as a friend."; header("Refresh:2; url=http://www.socialgrabbr.com/profile.php?profile_id={$req_user['id']}"); } else { ?> <form method='post' action='http://www.socialgrabbr.com/friends.php?type=request&request_id=<?=$_GET['request_id']?>'> Are you sure you want add <?=$req_user['username']?> as a friend?<br><br> <input type="submit" name="submit" value="Add Friend"> <input type="button" onclick="location.href='http://www.socialgrabbr.com/profile.php?profile_id=<?=$req_user['id']?>'" name="cancel" value="Cancel"> </form> <? } } else { echo "You have already added this person as a friend...<br><a href='". $_SERVER['HTTP_REFERER'] ."'>Go Back A Page</a>"; } } else { echo "Invalid Friend ID.."; } } } include("footer.php"); ?> anyone now? Quote Link to comment https://forums.phpfreaks.com/topic/86798-not-retrieving-info/#findComment-443664 Share on other sites More sharing options...
quickstopman Posted January 20, 2008 Author Share Posted January 20, 2008 bump Quote Link to comment https://forums.phpfreaks.com/topic/86798-not-retrieving-info/#findComment-444343 Share on other sites More sharing options...
quickstopman Posted January 21, 2008 Author Share Posted January 21, 2008 anybody!!!!!!!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/86798-not-retrieving-info/#findComment-444678 Share on other sites More sharing options...
priti Posted January 21, 2008 Share Posted January 21, 2008 Hi, $friend = mysql_query("SELECT * FROM users WHERE id = '{$sql1['friends_with']}'") or die(mysql_error()); $friend_stuff = mysql_fetch_array($friend); From above query you are going yo receive multiple records or unique set of data. Well it doesn't matter but if you are fetching particular id then use mysql_fetch_row($friend); Regards. Quote Link to comment https://forums.phpfreaks.com/topic/86798-not-retrieving-info/#findComment-444790 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.