Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Is this a valid SQL statement???

Is this a valid SQL statement???
Thread Tools
Registered User
Join Date: Jul 2003
Location: San Jose
Status: Offline
Reply With Quote
Jul 22, 2003, 09:51 PM
 
i'm trying to set up the shell for an online shopping cart and have everything working.... except the 'update' function. so, if someone has 1 item in their cart and wants 82, it all goes smoothly except the the database doesn't update with the new value.

i suspect it's the SQL statement, but i don't see any errors.... any ideas???

switch statement that gets called from the form
switch ($_GET['action'])
{
case "add_item":
{
AddItem($_GET['sessionId'], $_GET['id'], $_GET['qty']);
ShowCart();
break;
}
case "update_item":
{
UpdateItem($_GET['cart'], $_GET['qty']);
ShowCart();
break;
}
case "remove_item":
{
RemoveItem($_GET['cart']);
ShowCart();
break;
}
default:
{
ShowCart();
}
}

SQL statement
// Update items in cart
function UpdateItem($cartId, $qty) {
include ("config.php");

$query = "UPDATE cart SET qty = $qty WHERE cartId = $cartId";
$result = mysql_query($result);
}

the full code for this can be downloaded here.
(Last edited by mzllr; Jul 22, 2003 at 09:57 PM. )
     
Fresh-Faced Recruit
Join Date: Feb 2001
Status: Offline
Reply With Quote
Jul 22, 2003, 10:18 PM
 
you're not passing the $query var to mysql_query():

$query = "UPDATE cart SET qty = $qty WHERE cartId = $cartId";
$result = mysql_query($result);

fixed:

$query = "UPDATE cart SET qty = $qty WHERE cartId = $cartId";
$result = mysql_query($query );
     
mzllr  (op)
Registered User
Join Date: Jul 2003
Location: San Jose
Status: Offline
Reply With Quote
Jul 22, 2003, 10:25 PM
 
thanks, drew... i'm a dork, i caught the mistake right after i posted.

it all works now...
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:12 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2