So I am working on some code that inserts a piece of text and an id into a table. I send the code the text and the user's name. I want to take the username, and select the id that corresponds to it from the users table. I then insert that into the text table.
I have tried this:
$id = mysql_query("SELECT users.id FROM users WHERE name='$username'");
mysql_query("INSERT INTO `shouts` (`id`, `user`, `text`, `datetime`) VALUES (NULL, '$id', '$text', '$datetime');");
But it does not work, because the variable $id holds sql data. How can i turn that data into and integer?