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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.