Php 错误号:2除零错误
我得到这个错误: 错误:2 文本:除零 位置:C:\xampp\htdocs\final\classes\customer.php,第183行,2010年4月2日下午3:49 我在我的类Customer中具有以下功能Php 错误号:2除零错误,php,mysql,Php,Mysql,我得到这个错误: 错误:2 文本:除零 位置:C:\xampp\htdocs\final\classes\customer.php,第183行,2010年4月2日下午3:49 我在我的类Customer中具有以下功能 public static function GetQuotationDetails($string) { $sql = 'SELECT I.name, I.discounted_price, I.other_name FRO
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);
}
那么
$this->results = Customer::GetQuotationDetails('grinder');
我也用同样的方式回应了结果
echo $obj_quotations->results;
有人能帮我吗?
当我运行sql代码并将:string替换为“grinder”时,它会显示所需的记录。您的问题中突出显示的语法完全是免费的。%符号不被视为字符串的一部分。他们实际上是在计算两个字符串相除的剩余部分 您需要在SQL语句中转义单引号,因此:
...LIKE CONCAT( \'%\', :string, \'%\' ))
或者我更喜欢在语句中使用双引号字符串,这样单引号就不会被视为特殊了。有人能帮我吗?:没有,你没有指定错误发生的位置,你的代码也没有分区,所以很可能你没有发布相关代码。我已经发布了上面所有的相关代码。是的,如果字符串包含单引号,通常使用双引号分隔字符串以提高代码可读性。