在一些網站的模塊,我有一個代碼Drupal的模塊MySQL錯誤
function q_cart_add($node) {
global $user;
//drupal_set_title('Добавление товара в корзину');
drupal_set_title('Товар добавлен в корзину');
if (!user_access('add to cart'))
return '<p>У вас не достаточно прав для добавления в корзину</p>';
if ($node -> type != 'kartochka')
return '<p>В корзину можно положить только товар</p>';
$added = false;
if ($user -> uid) {
$added = db_result(db_query('SELECT `added` FROM {q_cart} WHERE `uid` = %d, `nid` = %d', $user -> uid, $node -> nid));
if (!$added) {
db_query('INSERT INTO {q_cart} (`uid`, `nid`, `added`) VALUES (%d, %d, %d)', $user -> uid, $node -> nid, time());
}
} else {
foreach (isset($_COOKIE['q_cart']) && ($cart = json_decode($_COOKIE['q_cart'])) ? $cart : array() as $item)
if ($item -> nid == $node -> nid) {
$added = true;
break;
但在管理面板報告在Drupal(6)我有錯誤:
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 ' `nid` = 806' at line 1 query:
SELECT `added` FROM q_cart WHERE `uid` = 1, `nid` = 806 in file...
哪些錯誤,此代碼?
'''是一個問題......它缺乏條件 – Julien 2012-08-08 07:23:03
的引號可以這是因爲使用'123'而不是'123'? (行情) – Avdept 2012-08-08 07:32:36