Originally posted by DeltaRho2K
I know this is going to sound silly, but..... Are you sure there is a user name in your users.username field that is joely2?
That is what it is checking - to see if it is present. If not, great. If it is, stop and report back.
This error is occuring with the bit of script in my signup that checks to see if someone has that username already
When your query comes back empty, it usually means just that. There was no result set...
Judging from the MySQL Help pages, it means there was no query passed in the mysql_query() bit, I think. But there must be, since I can echo it just before it actually does the query.
Also I can echo $username, $POST['username'] and $SESSION['username'] no problem at all during that stage.
Also, where are these values defined? (just out of curiosity.) I just wanted to make sure you were connecting to the right DB. (In case you had a users table in two different DBs)
$mysqldatabase, $mysqlconnection
Yup, connecting to right DB, as it works fine if I refresh the page (which is a very odd thing!). The MySQL connection info is defined in the include at the stop of the script (functions.php).
I know this all sounds silly, but sometimes, you have to go back to basics to find problems you think are more complex than they really are...
Yeah. I've also tried commenting out all of my stuff. Commenting out the MySQL queries, and it processes the registration fine.
I tried rewriting the MySQL query, using someone's suggestion from above:
mysql_select_db($mysqldatabase, $mysqlconnection);
$sql = "SELECT username FROM users WHERE username='$_POST['username']'"; //search for username
$result = mysql_query($sql) or die(mysql_error());
$num = mysql_num_rows($result);
// if($num > 0){
// $regerror .= " - That username exists. Please choose another";
// $username = "";
// fatalerror();
// exit;
// }
echo $num;
That does the same. "Query was empty".
However, upon a refresh, I get the HTML results, the data is added, and the number '0' at the top of the page (result of echo $num).
hat happens if you put in the name "joely2" instead of the variable in your SQL?
Well I tried that. And I also tried putting the Query into the mysql_query(); itself. Still the same error 🙁
lastly, move all of your connection, and SQL to a different page (without all of the error checking) and see if it queries things fine there...
I'll try that next!