ERRNO: 2 Division by zero error
I am getting this error : ERRNO: 2 TEXT: Division by zero LOCATION: C:\xampp\htdocs\final\classes\customer.php, line 183, at April 2, 2010, 3:49 pm
I have the following function in my class Customer
public static function GetQuotationDetails($string)
{
$sql = 'SELECT I.name, I.discounted_price, I.other_name
FROM item I
WHERE ( I.name LIKE CONCAT( '%', :string, '%' )) ---line 183
AND T.item_name=:string';
$parameters = array(':string' => $string);
DB::GetAll($sql,$parameters);
}
Then,
$this->results = Customer::GetQuotationDetails('grin开发者_如何学编程der');
and i echo the results by
echo $obj_quotations->results;
Can anyone help me? When i run the sql code and replace :string by 'grinder', it displays the required records.
The syntax highlighting in your question is a dead give-away. The %
signs aren't treated as part of the string. They are actually trying to compute the remainder of dividing two strings.
You need to escape the single-quotes in the SQL statement, thus:
...LIKE CONCAT( \'%\', :string, \'%\' ))
Or (my preference) use a double-quoted string for the statement so that the single-quotes aren't treated as special.
精彩评论