First, try to complete that query by executing it. You do that by adding the next couple of lines right after the $query:
$result = mysql_query($query); // supposing you already established the connection and that you use MySQL. $num_rows = mysql_num_rows($result); // To count how many matches where found Then compare the names that you have stored with the new one like: if ($num_rows > 0) { echo "Sorry, that name is taken"; } else ($num_rows == 0) { echo "Welcome ".$name.""; } This is made from memory, so it might not work right on. Hope it helps, Cesar L. Aracena [EMAIL PROTECTED] [EMAIL PROTECTED] (0299) 156-356688 Neuquén (8300) Capital Argentina -----Mensaje original----- De: - [ Paul Ferrie ] - [mailto:[EMAIL PROTECTED]] Enviado el: lunes, 06 de enero de 2003 10:16 Para: [EMAIL PROTECTED] Asunto: [PHP] php $query help 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php