RE: [PHP] a conditionial insert

From: Date: Tue, 19 Nov 2002 03:10:08 +0000
Subject: RE: [PHP] a conditionial insert
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-125022@lists.php.net to get a copy of this message
Hi just wanted to say thanks Justin.. I've got it working with your idea .... I needed to change this line.... if($result && mysql_num_rows($result) > 0) to if ($result && mysql_num_rows($result) < 1) and it works a treat. Thanks Peter > I'm no expert, but I think $result will return true if the query was > successful, it's not dependant on if there were rows returned. > > To check if there was a row returned, use mysql_num_rows($result) > > > $result = mysql_query("SELECT * FROM resellers WHERE > company='$_POST[company]'"); > if($result && mysql_num_rows($result) > 0) > { > // insert > } > else > { > //something else > } > > > > Justin French > -------------------- > http://Indent.com.au > Web Developent & > Graphic Design > -------------------- > >

« previous php.general (#125022) next »