Click to See Complete Forum and Search --> : mySQL and PHP linking problems


bradenkeithcom
01-05-2008, 11:45 PM
So I have two tables with in the database braden_gaming. One is for my shoutbox and one is for my Users... where people login, etc. Now on my shoutbox page I have the messages going to shoutbox database (as well as some other information). I'm wanting to get the "Author" to be the user's login username and to be automatically inserted without them typing it in or having the option to change it. Look below to see what I did.

<INPUT TYPE="hidden" NAME="author" value="<?php echo $username; ?>">

That's not a problem. The problem is instead of writing the name is rights, Resource #X, replace X with the number that corresponds to there signup order.

So where's my problem? This is how I'm calling the information from table "users"
$username = mysql_query("SELECT * FROM users WHERE username = '$username'") or die (mysql_error());

Please help in whatever way you can.

ss1289
01-06-2008, 12:01 AM
try this.

$uname = mysql_query("SELECT * FROM users WHERE username = '$username'") or die (mysql_error());
$name = mysql_fetch_array($uname);
$user_name = $name["username"];

<INPUT TYPE="hidden" NAME="author" value="<?php echo $user_name; ?>">

bradenkeithcom
01-06-2008, 12:47 AM
no cigar. thanks for the try though. now i'm not getting anything as the author