php $query help

From: Date: Mon, 06 Jan 2003 13:16:05 +0000
Subject: php $query help
Groups: php.general 
Request: Send a blank email to php-general+get-130394@lists.php.net to get a copy of this message
Here is my problem I have created a user login system (flash+php+mysql) And it just about works Here's the prob when i go to register as a new user the code wont properly check to see if the username already exsist's in the DB, I am pretty sure the problem lies in my first $query PHP:------------------------------------------------------------------------ ------ $query = "SELECT name FROM contacts WHERE name='$name'"; if ($name == $name) { print "loginT=UserName in Use"; }else{ $query = "INSERT INTO contacts (name, pass, email, id) VALUES ('$name', '$pass', '$email', NULL);"; } $result = mysql_query($query); // Gets the number of rows affected by the query as a check. $numR = mysql_affected_rows($Connect); if ($numR == 0) { // Sends output to flash print "loginT=Error - Register Again"; } else if ($numR == 1) { // Sends output to flash print "loginT=Success&checklog=1"; } ---------------------------------------------------------------------------- -- If i take out PHP:------------------------------------------------------------------------ ------ $query = "SELECT name FROM contacts WHERE name='$name'"; if ($name == $name) { print "loginT=UserName in Use"; ---------------------------------------------------------------------------- -- THe login system works fine but dupilcate entries can be submitted to the database. Please help i would love to get this up and running Cheers

« previous php.general (#130394) next »