Hi,
I've been staring myself blind on this but I can't find the error...
$param is passed to the function as an array.
I get this error message:
Error performing query :You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE threat=1' at line 1
function retrieveMsg($param){
//make query
print $param[0];
$query = 'SELECT * FROM rappo_msgbox WHERE id>0 ';
$paramOrder = array('threat', 'subject', 'sentDateTime', 'sentBy', 'priority', 'status', 'archieve', 'catagoryID');
for ($i=0; $i<=(count($paramOrder)); $i++){
if (isset($param[$i])){
$query .= ' AND WHERE '.$paramOrder[$i].'='.$param[$i].'';
}
}
$result = mysql_query($query);
if (!$result){die ('Error performing query :' . mysql_error());}
else{
while ($row = mysql_fetch_array($result) ){
$subject = $row['subject'];
echo $subject;
echo "<br>"; }
echo $query;}
Any help would be very welcome!