Re: PHP Newbie Database Records?

From: Date: Mon, 16 Feb 2004 01:29:12 +0000
Subject: Re: PHP Newbie Database Records?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-177765@lists.php.net to get a copy of this message
In article <20040216003544.26244.qmail@pb1.pair.com>, colin_blunt@petcol.com says... > 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 > First, consider echo $query_qUsername to ensure that it contains what you think it does. Second, consider using mysql_error() after your call to the database to show the text of any error returned by mysql. -- Quod subigo farinam A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet?

« previous php.general (#177765) next »