On 30 May 2011 22:31, Nazish <nazish@xxxxxxx> wrote: > Hi all, > > I've run into a little barrier, and I'm wondering whether you have any > insights. I'm entering values into a MySQL database. Before running the > mysql_query, I'm checking if the value already exists (using mysql_num_rows > == 0). ÂIf the value already exists in the database, the page will echo > "Username already exists" and it won't insert the user's new value. It runs > that far, and echoes the message accordingly. However, if the username is > new, and does not exist in the database, the query dies (without leaving a > mysql error). > > I tried changing the Unique IDs in the database, but it doesn't seem to be > the issue. The syntax seems fine, as I used it for another similar page. Any > idea why it's dying? > > > Â Â Â Â$check = mysql_query("SELECT * FROM user WHERE > user_name='$user_name'") or die ("Unable to query database:".mysql_error()); > > Â Â Â Â$numrows = mysql_num_rows($check) or die ("Unable to search > database:".mysql_error()); Â-----> DIES HERE when a new value is entered. no > mysql_error msg. bla bla or die("more bla"); is a very bad way of handling error checks. In your particular case, your foot has been shot off because mysql_num_rows will return 0 (no rows match the query) and thus the die() is executed - but of course there's no error in the query, it executed just fine, this we know already. Moral: don't use ' or die();' for anything else than hands on debugging purposes Regards Peter -- <hype> WWW: plphp.dk / plind.dk LinkedIn: plind BeWelcome/Couchsurfing: Fake51 Twitter: kafe15 </hype> -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php