Re: Whats wrong with this statement.

From: Date: Sun, 14 Dec 2003 04:00:48 +0000
Subject: Re: Whats wrong with this statement.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-172660@lists.php.net to get a copy of this message
Philip J. Newman wrote:
<?php ## ASSUME DATABASE IS CONNECTED AND THESE 2 ITEMS ARE NOT IN THE DATABASE ## THIS RETURNS 1,0 all the time. $websiteUrl="http://www.philipnz.com/"; $websiteEmail="newmanpj@philipnz.com"; // CHECK TO SEE IF DATA MATCHS WHATS IN THE DATABASE. $sql = "SELECT hUrl,hContactEmail FROM hyperlinks_data"; $sql_result = mysql_query($sql, $connection) or die ("Could not get Query"); $exists_hUrl = "0"; $exists_hContactEmail = "0"; while ($row = mysql_fetch_array($sql_result)) { if ($websiteUrl==$row["hUrl"]) { $exists_hUrl = "1"; break; } if ($websiteEmail==$row["hContactEmail"]) { $exists_hContactEmail = "1"; break; } } Echo" $exists_hUrl, $exists_hContactEmail"; ?> --- Philip J. Newman Master Developer PhilipNZ.com [NZ] Ltd. info@PhilipNZ.com
The "break;" breaks out of the while loop, causing it to skip the second check and all remaining records. You should be doing this in the SQL: SELECT hUrl,hContactEmail FROM hyperlinks_data WHERE hUrl = "$websiteUrl" and hContactEmail = "$websiteEmail"; -- paperCrane <Justin Patrin>

« previous php.general (#172660) next »