Forum Moderators: coopster
when i use the && in the following statment, it does not work. and i have a massage with "Error processing request - check your query".
if(($SC!=null)&&($C==null)&&($Ci==null))
$result = mysql_query("select * from Customer where Country=" . "'$D'" . " and State=" . "'$SC'" . " and BType=" . "'$E'");
but when i use && in the following, they work.
if($SC!=null)
$result = mysql_query("select * from Customer where Country=" . "'$D'" . " and State=" . "'$SC'" . " and BType=" . "'$E'");
and
if(($C!=null)&&($B!=null)&&($Ci!=null)&&($SC!=null))
$result = mysql_query("select * from Customer where Country=" . "'$D'" . " and City=" . "'$F'" . " and State=" . "'$SC'" . " and Area=" . "'$A'" . " and BType=" . "'$E'");
both about are work
Could you tell me why, please
if you are testing using the exact same vars then version 1 and 2 are exactly the same and should both perform equally, as far as the query goes.
the first one says
if $SC is not null and $C is equal to null and $Ci is equal to null
the second says
if $SC is not null
the queries are exactly the same, so the added tested values only make a difference in whether the query will be executed, not in it's performance. Neither of the added tested values are used in the query.
what you should probably do is add some error checking to those queries so you can get the actual error from mysql and split out your query construction, this will help debugging as well. Your queries are also concatenated in a very strange way. Take a look at this
$q = "select * from Customer where Country='" . $D . "' and State='" . $SC . "' and BType='" . $E . "'";
// echo '<p>',$q;
$result = mysql_query($q) or die ('query at line xx died: ' . mysql_error());