Hi I'm trying to get a nice user reg going with an uathentication to check for multiple entries prompting the user to "try again" if their chosen name/pass is already in existance(there are other things planned even beyond that uath but its gotta get going before I start stripping tags or slashes or whatever else). I've gotten it to work with mysql_num_rows() but now it doesnt want to continue to work Im sure I've done something wrong - its throwing an error - can someone please look over my code and see if there is anything that sticks out to you?? Thanks.
-Jonabomer
/////////////HERES THE SET-UP//////////////
<?php
//make post variables easy to read/handle
$fname="$POST[FNAME]";
$lname="$POST[LNAME]";
$address="$POST[ADDRESS]";
$city="$POST[CITY]";
$state="$POST[STATE]";
$zip="$POST[ZIP]";
$email="$POST[EMAIL]";
$url="$POST[URL]";
$uname="$POST[UNAME]";
$pass="$POST[PASS]";
//sql transaction for user update
$sql_user_insert="INSERT INTO "
. "user "
. "(FNAME, LNAME, ADDRESS, CITY, STATE, ZIP, EMAIL, URL, UNAME, PASS) "
. "VALUES "
. "('$fname', '$lname', '$address', '$city', '$state', '$zip', '$email', '$url', '$uname', '$pass')";
//sql transactions for registration authentincation
$sql_user_select="SELECT UNAME "
. "FROM user "
. "WHERE UNAME='$uname'";
$sql_pass_select="SELECT PASS "
. "FROM user "
. "WHERE PASS='$pass'";
//puts sql transactions into variables
$addUser=mysql_query($sql_user_insert);
$auth_u=mysql_query($sql_user_select);
$auth_p=mysql_query($sql_pass_select);
?>
///////////HERE'S THE "ACTION"////////////
<?php
//echo"$sql_user_insert";<--works out
//create connection states
if($conn=mysql_connect(host, user, pass)){
echo"connection opened<br/>";
}
if(mysql_select_db(db_name, $conn)){
echo"DB changed<br/>";
}
if(mysql_num_rows($auth_u)>0){
echo"Sorry the user name you have chosen is currently in use - please choose another";
}elseif(mysql_num_rows($auth_p)>0){
echo"Sorry the pass word you have chosen is currently in use - please choose another";
}else{
if(mysql_query($sql_user_insert)){
echo"Thank you for registering";
}
}
?>
/////////////////HERE'S THE ERROR//////////
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
Is there a problem with the SQL? MySQL isnt throwing an error and I believe that I'm using the function correctly (it appears about exactly as in the script that works). I'm at a loss(????) - any help would be great!