Hi!
I've got these two tables:
files(id, name, type, size, date, user_id)
users (id, username, password)
Now I want to store users.id into files.user_id in order to be able to do CROSS JOIN.
The problem is that in the following script:
/* Get the name of the user and find its id fro users table */
session_start();
$user = $_SESSION['username'];
$sql = "SELECT id FROM users WHERE username = '$user' LIMIT 1";
$username = mysql_query($sql);
echo $username;
I get : Resource id #4
and when I try to INSERT it into files.user_id (which is int), off course, it gives me an error.
Isn't it correct to use the primary key of users as secondary key to files?
But why the id isn't plain 4 (int)? Is there another way to get it?
Thank you very much.