Jump to content

A simple problem causing alot of confusion.


gtrufitt

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.