Re: If (!$results) are true what am I missing

From: Date: Tue, 10 Jul 2001 05:33:22 +0000
Subject: Re: If (!$results) are true what am I missing
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-57075@lists.php.net to get a copy of this message
On Tue, 10 Jul 2001 14:37, Richard Kurth wrote: > What am I missing hear all I what to do is see if the domaname is > in the database and if it does print the error message if does not then > just move on without doing anything > > > $db = MYSQL_CONNECT($roothostname,$rootusername, $rootpassword) OR > DIE("Unable to connect to database"); mysql_select_db($dbName, $db); > $result = mysql_query( "SELECT * FROM customers WHERE domaname = > $domain1", $db); If (!$result) { > print_error("<b> This Domain Name $domain1 already exist please > select a new Domain Name </b> "); } $result will be true if your query returns a successful result - which may have 0 or more rows! Try using mysql_num_rows($result) and check whether it is zero (no records found) or non-zero (record exists) -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA I keep my .BAT files in D:\BELFRY

« previous php.general (#57075) next »