Hello,
I am working on a query that pulls search terms out of a form, but am getting a parse error. I am hoping one of the PHP gurus on this board can give me a tip.
The parse error indicates its the line with the first "if" statement.
thanks in advance.
<?
if ($HTTP_POST_VARS["Field"]$Count>0)
{
$strSQL="";
for ($intCount=1; $intCount<=$HTTP_POST_VARS["Field"].$Count; $intCount=$intCount+1)
{
$strSQL=$strSQL.$HTTP_POST_VARS["Field"]($intCount).", ";
}
$strSQL=substr($strSQL,0,strlen($strSQL)-2);
$strSQL="SELECT ".$strSQL." FROM canada WHERE ";
$parameterStr="";
if ($HTTP_POST_VARS["region"]!="")
{
$parameterStr="Region = '".$HTTP_POST_VARS["region"]."'";
}
if ($HTTP_POST_VARS["type"]!="")
{
if ($parameterStr=="")
{
$parameterStr="Type ".$HTTP_POST_VARS["type"]."";
}
else
{
$parameterStr=$parameterStr." AND Type ".$HTTP_POST_VARS["type"]."";
}
}
if ($HTTP_POST_VARS["name"]!="")
{
if ($parameterStr=="")
{
$parameterStr="Name LIKE '%".$HTTP_POST_VARS["name"]."%'";
}
else
{
$parameterStr=$parameterStr." AND Name LIKE '%".$HTTP_POST_VARS["name"]."%'";
}
}
if ($HTTP_POST_VARS["contact"]!="")
{
if ($parameterStr=="")
{
$parameterStr="Contact LIKE '%".$HTTP_POST_VARS["contact"]."%'";
}
else
{
$parameterStr=$parameterStr." AND Contact LIKE '%".$HTTP_POST_VARS["contact"]."%'";
}
}
if ($HTTP_POST_VARS["email"]!="")
{
if ($parameterStr=="")
{
$parameterStr="Email LIKE '%".$HTTP_POST_VARS["email"]."%'";
}
else
{
$parameterStr=$parameterStr." AND Email LIKE '%".$HTTP_POST_VARS["email"]."%'";
}
}
if ($HTTP_POST_VARS["status"]!="")
{
if ($parameterStr=="")
{
$parameterStr="Status = '".$HTTP_POST_VARS["status"]."'";
}
else
{
$parameterStr=$parameterStr." AND Status = '".$HTTP_POST_VARS["status"]."'";
}
}
$strSQL=$strSQL.$parameterStr;
}
print "<BR><BR>";
?>