Simple mysql query not working!
Posted: Mon May 19, 2003 1:33 am
Hi all! I orginally put this up in the General Discussion forum and realised this was probably a better spot for it.
trying to debug a record insertion form for my blog page.
What i want to happen is:
-User Enters their Nickname into a form
-Then I determine the User Id based on this nickname (since they are both in the 'users' table)
-Insert the blog with user id to the 'posts' table
Pretty simple eh? So what am i doing wrong?
<?php
$username = $HTTP_POST_VARS['nickname'];
$query_1 = "SELECT USER_ID FROM users WHERE NICK_NAME = $username";
$userid = mysql_query($query_1);
?>
Note that $userid is a number. If i manually set $userid = 4, my insertion code (not shown) works great. The problem is that $userid is not being set to a valid integer, infact it remains NULL... Whats happening!
Thx in advance!
trying to debug a record insertion form for my blog page.
What i want to happen is:
-User Enters their Nickname into a form
-Then I determine the User Id based on this nickname (since they are both in the 'users' table)
-Insert the blog with user id to the 'posts' table
Pretty simple eh? So what am i doing wrong?
<?php
$username = $HTTP_POST_VARS['nickname'];
$query_1 = "SELECT USER_ID FROM users WHERE NICK_NAME = $username";
$userid = mysql_query($query_1);
?>
Note that $userid is a number. If i manually set $userid = 4, my insertion code (not shown) works great. The problem is that $userid is not being set to a valid integer, infact it remains NULL... Whats happening!
Thx in advance!