Need Help with PHP Syntax Error
I am struggling with this error message "Parse error: syntax error, unexpected T_IF" for line 66 that I keep getting. Here's the code that I'm using that I got with help from users of this website, which is supposed to run a multiple parameter search on a mysql database. The red text is line 66. I am just beginning to learn PHP and I can't figure out what to do with it. Is it possible to have two if statements following each other like that? Also, as I mentioned, I was given this code from help from this forum, but I don't understand what the purpose is of the variable $where. Will this code also work without it? Thanks in advance for any help.
$query_rsMainItems = 'SELECT * FROM mainitems'; $where = false; if (isset($_GET['category']) && !empty($_GET['category'])) { $query_rsMainItems .= ' WHERE category = '. GetSQLValueString($_GET['category'], 'text'); $where = true; } if (isset($_GET['price']) && !empty($_GET['price'])) { if ($where) { $query_rsMainItems .= ' AND '; } else { $query_rsMainItems .= ' WHERE '; $where = true; } $query_rsMainItems .= 'price = ' . GetSQLValueString($_GET['price'], 'text'); } if (isset($_GET['time1']) && !empty($_GET['time1'])) { if ($where) { $query_rsMainItems .= ' AND '; } else { $query_rsMainItems .= ' WHERE '; $where = true; } $query_rsMainItems .= 'time1 = ' . GetSQLValueString($_GET['time1'], 'text'); } if (isset($_GET['time2']) && !empty($_GET['time2'])) { if ($where) { $query_rsMainItems .= ' AND '; } else { $query_rsMainItems .= ' WHERE '; $where = true; } $query_rsMainItems .= 'time2 = ' . GetSQLValueString($_GET['time2'], 'text'); } if (isset($_GET['city']) && !empty($_GET['city'])) { if ($where) { $query_rsMainItems .= ' AND '; } else { $query_rsMainItems .= ' WHERE '; $where = true; } $query_rsMainItems .= 'city = ' . GetSQLValueString($_GET['city'], 'text'); } if (isset($_GET['zip']) && !empty($_GET['zip'])) { if ($where) { $query_rsMainItems .= ' AND '; } else { $query_rsMainItems .= ' WHERE '; $where = true; } $query_rsMainItems .= 'zip = ' . GetSQLValueString($_GET['zip'], 'text'); } if (isset($_GET['neighborhood']) && !empty($_GET['neighborhood'])) { if ($where) { $query_rsMainItems .= ' AND '; } else { $query_rsMainItems .= ' WHERE '; } $query_rsMainItems .= 'neighborhood = ' . GetSQLValueString($_GET['neighborhood'], 'text');