Page 1 of 1

Question

Posted: Sun Jul 27, 2003 5:01 pm
by Nitro

Code: Select all

$query = mysql_query("SELECT username FROM verify, username FROM account WHERE username='$username'");
	$num = mysql_num_rows($query);
Can anyone please tell me why that doesnt work, and how I can make it work.

Thanks,

Posted: Sun Jul 27, 2003 6:27 pm
by patrikG
What's the error message?

...

Posted: Sun Jul 27, 2003 7:53 pm
by kettle_drum
You probably need to suggest which username field you want to select. I.e. SELECT username.table_name FROM

Posted: Mon Jul 28, 2003 2:36 am
by Nitro
Here is the error message:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/nitro/public_html/signup.php on line 95

Posted: Mon Jul 28, 2003 6:28 am
by mikusan
I have had that annoying pointless error for the longest amount of time. It is related to the rest of the code and not only those 2 lines... you need to show us more code especially if you have an if statement somewhere there because that's where my problem arose.

I think with more code we can help you.

Posted: Mon Jul 28, 2003 8:46 am
by twigletmac
You've got 2 FROM clauses in that SQL statement. It looks like you'll probably have some other problems with it too so try this, which should give you a better, MySQL generated, error:

Code: Select all

$sql = "SELECT username FROM verify, username, account WHERE verify.username = '$username'";
$query = mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');
Mac

Here is the whole thing:

Posted: Mon Jul 28, 2003 9:30 am
by Nitro

Code: Select all

$query = mysql_query("SELECT username FROM verify, username FROM account WHERE username='$username'");
	$num = mysql_num_rows($query);
	if ($num > 0)
	&#123;
	echo "<center><b>Error!</b> The username "$username" is already in use. Please try a differant one.";
	form();
	exit();
	&#125;

Posted: Mon Jul 28, 2003 9:43 am
by twigletmac
Did you try the code snippet I posted?

Mac

Posted: Mon Jul 28, 2003 9:55 am
by Drachlen

Code: Select all

<?php
$result = mysql_query("SELECT a.* FROM `verify` as a, `account` as b WHERE a.username = '$username' AND b.username = '$username'") or die ("b0rked: ".mysql_error());
if (mysql_num_rows($result) >= 1) {
?>
Tested to an extent, should work...