Re: PHP Newbie Database Records?
| From: | André Cerqueira | Date: | Mon, 16 Feb 2004 03:30:23 +0000 |
| Subject: | Re: PHP Newbie Database Records? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-177766@lists.php.net to get a copy of this message | ||
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I believe you forgot to read the manual.
$query_qUsername = "SELECT * FROM users WHERE username = '$username'"; $num_rows = mysql_num_rows($query_qUsername);$query_qUsername is a String mysql_num_rows want a result resource as argument You have no result till you do mysql_query Read these please: http://www.php.net/mysql http://www.php.net/mysql_query Petcol wrote:
PHP Newbie, I'm trying to find out if a username already appears in my database. I have two users in my table, one is colin so when I enter a username of colin I would normally under ColdFusion anyway just to something like: <cfif $query_qUsername.RecordCount GT 0> User already exists do something else, like throw the user back an error. </cfif> My Query works $query_qUsername = "SELECT * FROM users WHERE username = '$username'"; I've tried a number of different things here and everything either comes back with nothing, or throws an error. $num_rows = mysql_num_rows($query_qUsername); echo $num_rows; // this comes back with nothing, I was expecting a numeric of 1 exit; Regards Col -----BEGIN PGP SIGNATURE-----Version: GnuPG v1.2.4 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFAMDlSaxdA/5C8vH8RAv8qAJ0XeA+wmVsDIhxBPusnqfFl5Y+7sgCdHotu xuIp7e5y/0NJle1QG8Gh4aQ= =nqt3 -----END PGP SIGNATURE-----