gtrufitt Posted March 15, 2008 Share Posted March 15, 2008 ok. All I am trying to do is echo the f_name from the user table using the friendid variable from GET to get the ID of the person from the user table. But for some reason it is not working... Im surely doing something very small wrong? <?php mysql_connect("localhost", "admin", "admin") or die("Cannot connect to DB!"); mysql_select_db("padgate") or die("Cannot select DB!"); $friendid = $_GET['friendid']; $getfriend = "SELECT id, friendid FROM friends WHERE id = '$sesid' AND friendid = '$friendid'"; $fr = mysql_query($getfriend) or die(); $countfr = mysql_num_rows($fr); $getfname = "SELECT f_name FROM user WHERE id = '$friendid'"; $fn = mysql_query($getfname) or die(); $friendname = $fn['f_name']; ?> <?php if ($countfr == 0) { $addfriend = "INSERT INTO friends (id, friendid) VALUES ('$sesid', '$friendid')"; mysql_query($addfriend) or die(); echo 'You have added ' . $friendname . 'as your friend!' ; } else { echo 'You are already friends with' . $friendname; } ?> Thanks Quote Link to comment Share on other sites More sharing options...
JD* Posted March 15, 2008 Share Posted March 15, 2008 What is the error/result that you get? A blank return? Quote Link to comment Share on other sites More sharing options...
gtrufitt Posted March 15, 2008 Author Share Posted March 15, 2008 Yea, just a blank return. Quote Link to comment Share on other sites More sharing options...
dotBz Posted March 15, 2008 Share Posted March 15, 2008 try this: $fn = mysql_query($getfname) or die(); $friendname = mysql_result($fn, 0); Quote Link to comment Share on other sites More sharing options...
gtrufitt Posted March 15, 2008 Author Share Posted March 15, 2008 Ace, thanks alot, that worked 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.