Jump to content

[SOLVED] can't seem to input variables and update table


contra10

Recommended Posts

im trying to input some variables and only afew are entering and i can't seem to update a value

	<?php
mysql_connect("localhost", "root", "") or die(mysql_error()); 
mysql_select_db("registration") or die(mysql_error()); 

if(is_numeric($_GET['request'])){

$id = $_GET['request'];

  $friend= "SELECT * FROM users WHERE id = '$id'";
$friendget = mysql_query($friend) or die(mysql_error());

while ($friendrequest = mysql_fetch_assoc($friendget))
{
$usernamef = "{$friendrequest['username']}";
$usernamefid = "{$friendrequest['userid']}";
$usersex = "{$friendrequest['sex']}";
	$usercity = "{$friendrequest['city']}";
	$usercountry = "{$friendrequest['country']}";
	$userfrid = "{$friendrequest['frid']}";
echo "<table border ='1' align='center'>";
echo "<tr>";
echo "<td width='400' height='300'>$usernamef</td>";
echo "</tr>";
echo "<tr>";
echo "<td>$usersex, $usercity, $usercountry</td>";
echo "</tr>";
}
echo "</table>";
}

if (isset($_POST['add'])) {

$query = "SELECT * FROM users WHERE username = '$username'";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);

$userid = "{$row['id']}";

$friendaccept= 2;

	$query2= "UPDATE friend_request SET value = '$friendaccept' WHERE username = '$usernamef' AND requestname = '$username'";
$result2 = mysql_query($query2) or die(mysql_error());

$insert = "INSERT INTO friends (userid, username, friendid, friendname)
VALUES ('$userid', '$username', '$usernamefid', '$usernamef')";
$add_group = mysql_query($insert) or die(mysql_error());	

?>

i can't update the value to 2 and for some reason only part of variables are entering the table, userid and username are entering while usernamefid and usernamef won't enter

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.