Error prevention

From: Date: Tue, 13 Mar 2001 16:05:12 +0000
Subject: Error prevention
Groups: php.db 
Request: Send a blank email to php-db+get-7404@lists.php.net to get a copy of this message
I'm baffled (again ....) In my mql database I'm doing: SELECT cl_login FROM client WHERE cl_login = "xxx"; and if "xxx" exists I get the result xxx while if it doesn't exist I get an empty string. In PHP I'm doing $querytest = "SELECT cl_login FROM client WHERE cl_login = '$txtLogin';"; $testresult = mysql_query($querytest, $mysql_link); if ($testresult) { print "Error: Client already in database."; exit; } Now, no matter what* I still get a result of the query: Resource id # 7 (i put in echo $testresult; when the routine didn't work). * That I get Resource id ... if I have a cl_login = xxx or if I don't have one. What's !¤#!"#¤ going? How do I check for a duplicate before writing it to the database? (Short of putting UNIQUE on the table, which I suppose would result in an error).

« previous php.db (#7404) next »