Parse error: syntax error, unexpected ';' in /home/realcas/public_html/eshop/ecms/system/classes/database.php on line 29
This is the code on line 29
return empty($resultArray) ? "Error in Query " ? json_encode($resultArray);
this is the section of code that is the issue
public function select($table,$options,$where,$orderby)
{
$options = empty($options) ? "*" : $options;
$where = empty($where) ? "1=1" : $where;
$orderby = empty($orderby) ? "" : $orderby;
$qry = "SELECT $options FROM $table WHERE $where $orderby ";
$result = mysql_query($qry) or die(json_encode(array("error",mysql_error())));
while(($resultArray[] = mysql_fetch_assoc($result)));
return empty($resultArray) ? "Error in Query " ? json_encode($resultArray);
return json_encode($resultArray);
}
You want probably this one
return empty($resultArray) ? "Error in Query " : json_encode($resultArray);
because its
($condition) ? "condition is true" : "condition is false";
I see you're using it already, so I assume it was just a typo
Also remove this line
return json_encode($resultArray);
because it's unnecessary and never will happen. Additionally I'm not sure that your while loop is correct.
Result
public function select($table,$options,$where,$orderby)
{
$options = empty($options) ? "*" : $options;
$where = empty($where) ? "1=1" : $where;
$orderby = empty($orderby) ? "" : $orderby;
$qry = "SELECT $options FROM $table WHERE $where $orderby ";
$result = mysql_query($qry) or die(json_encode(array("error",mysql_error())));
while(($row = mysql_fetch_assoc($result))){ $resultArray[] = $row; }
return count($resultArray) < 1 ? "Error in Query " : json_encode($resultArray);
}
First of all, you don't need the last return
statement, that's already covered by the previous ternary op.
Secondly, the other return
should look like this:
return empty($resultArray) ? "Error in Query " : json_encode($resultArray);