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 Link to comment https://forums.phpfreaks.com/topic/96313-a-simple-problem-causing-alot-of-confusion/ 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? Link to comment https://forums.phpfreaks.com/topic/96313-a-simple-problem-causing-alot-of-confusion/#findComment-493013 Share on other sites More sharing options...
gtrufitt Posted March 15, 2008 Author Share Posted March 15, 2008 Yea, just a blank return. Link to comment https://forums.phpfreaks.com/topic/96313-a-simple-problem-causing-alot-of-confusion/#findComment-493014 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); Link to comment https://forums.phpfreaks.com/topic/96313-a-simple-problem-causing-alot-of-confusion/#findComment-493016 Share on other sites More sharing options...
gtrufitt Posted March 15, 2008 Author Share Posted March 15, 2008 Ace, thanks alot, that worked Link to comment https://forums.phpfreaks.com/topic/96313-a-simple-problem-causing-alot-of-confusion/#findComment-493017 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.