【发布时间】:2014-03-03 07:23:48
【问题描述】:
$cuntRs = $this->db->query("SELECT count(*) as cunt from " . DB_PREFIX . "vendhq_product");
if($cuntRs->row["cunt"]==0) {
foreach ($json["products"] as $dept){
echo "<strong> Product ". $i++ ."</strong><br/>";
$passval=$i;
echo $dept["name"]."<br/>"; echo $dept["id"]."<br/>";
$this->addVendHQproducts($dept,$passval);
}
}
function addVendHQproducts($dept,$pro_id) {
$this->db->query("INSERT INTO " . DB_PREFIX . "vendhq_product SET id = '" . $pro_id . "', vendhq_id = '" . $dept["id"]. "', name = '" . $dept["name"]. "', description = '" . $dept["description"]. "',image = '" . $dept["image"] . "', image_large = '" . $dept["image"]. "', tag = '" . $dept["tags"]. "', price = '" . $dept["price"] . "', supplier_name = '" . $dept["supplier_name"] ."'");
}
?> 输出:
Product 0
.........1
...........3..
Fatal error: Uncaught exception 'ErrorException' with message 'Error: 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 's server</p>',image = 'http://mohamedkaremullasha.vendhq.com/images/placeholder/' at line 1<br />Error No: 1064<br />INSERT INTO oc_vendhq_product SET id = '5', vendhq_id = 'bbeef777-9ac0-11e3-a0f5-b8ca3a64f8f4', name = 'TradeSender', description = '<p>trade sender iphone and ipod application to receive instant updates from ambibroker's server</p>',image = 'http://mohamedkaremullasha.vendhq.com/images/placeholder/product/no-image-white-thumb.png', image_large = 'http://mohamedkaremullasha.vendhq.com/images/placeholder/product/no-image-white-thumb.png', tag = 'share market, share updates', price = '100', supplier_name = 'Hibrise Tech -Suppliers'' in /Applications/XAMPP/xamppfiles/htdocs/mks/opencart-1.5.6.1/upload/system/database/mysqli.php:40 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/mks/opencart-1.5.6.1/uplo in
/Applications/XAMPP/xamppfiles/htdocs/mks/opencart-1.5.6.1/upload/system/database/mysqli.php 第 40 行
//请告诉我如何处理php中的错误异常
【问题讨论】:
-
你应该把你的专栏的别名改成一个好听的
-
可能是错字@ShankarDamodaran 也许 OP 的意思是“计数”哈哈
-
我收回 @ShankarDamodaran 这不是一个错字。
-
@Fred-ii- 我不这么认为,错别字可能不会出现两次。 OP可能甚至不知道这意味着什么。 @ OP 接受我的两分钱建议,并真正改变这个别名。
-
确实,看完第 4 行后,是一个死的让步 @ICanHasCheezburger (疲倦的眼睛)
标签: php mysql phpmyadmin opencart