Warning but working...?

wxdqz

New Member
hi there,

got something that's got me stumped. i'm doing a registration sort of thing, where a user can submit through a form, and it adds a row in a database of users. simple. but it is giving me a SQL warning! i can't work out why. here's the snippet of code:

$db = mysql_connect(DB_HOST, DB_USERNAME, DB_PASS);
mysql_select_db(DB_DBNAME, $db);
$db_usercheck = "SELECT * FROM ".DB_USERS." WHERE login='".$login."'";
$db_result = mysql_query($db_usercheck, $db);
if(mysql_num_rows($db_result) > 0){
shutdown("This login is already used. Please try another.");
} else {
$db_insert = "INSERT INTO ".DB_USERS." VALUES (NULL,'" . $login . "','" . $password . "','" . $email . "'," . $visible . ",'USER')";
$db_result = mysql_query($db_insert, $db);

here's the behaviour:
a) i am getting a warning: Warning: Supplied argument is not a valid MySQL-Link resource in /..(etc)../modules/adduser.php on line 61 - Line 61 is the last line of code quoted above, the mysql_query.
b) putting in an existing user locates that fine, with no warning. so i know it's connecting to the database correctly.
c) it works! i'm getting this bizarre Warning, but the data is still being written into the database!
d) to confirm that, outputting the value of $db_insert and pasting it straight onto mysql commandline works also, so it's not a syntax issue that i can tell.

please help, i'm ripping my hair out!

thank you,

david
 
Back
Top