News:

Support the VirtueMart project and become a member

Main Menu

Error on SaveCart function

Started by wildwolf0, June 01, 2008, 23:08:25 PM

Previous topic - Next topic

wildwolf0

Hi VM team,

I'm doing codes on a project using VM 1.1 and need to shown user's cart contents after they relogin.

I saw VM 1.1 has the function and also found the codes in ps_cart.php and DB name #_vm_cart. But the function is not working as I think. The problem is the cart content only shown in SESSION but DB and the cart shown for all users not single ID.

So I tracked the codes, and enabled the debug function in backend. An error is shown with these coded from function saveCart() in ps_cart.php. The error is from these lines:
$q = "REPLACE INTO `#__{vm}_cart` (`user_id`, `cart_content` ) VALUES ( ".$GLOBALS['auth']['user_id'].", '$cart_contents' )";
$db->query( $q );

The error shown as below:

Notice: 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 '; Pages:20_Pages";}}' )' at line 1 in /home/flyove5/public_html/albums/includes/database.php on line 307

/home/flyove5/public_html/albums/administrator/components/com_virtuemart/classes/ps_database.php:127
/home/flyove5/public_html/albums/administrator/components/com_virtuemart/classes/ps_cart.php:578
/home/flyove5/public_html/albums/administrator/components/com_virtuemart/classes/ps_cart.php:255
/home/flyove5/public_html/albums/components/com_virtuemart/virtuemart_parser.php:246
/home/flyove5/public_html/albums/components/com_virtuemart/virtuemart.php:22
/home/flyove5/public_html/albums/index.php:236


Is this a bug or not? I will correct it myself.

Yale

wildwolf0

OK, after one hours debuging, I found it's my fault on attribute content. I put a string 20' as attribute. The character "'" made this mysql query error.