I have been trying with no success to get this tutorial to work!

Building a Persistent Shopping Cart with PHP and MySQL

http://www.macromedia.com/devnet/mx/dreamweaver/articles/php_cart.html

When I run the code, I get

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /cart.php/on line 155

here's the problem - while($row = mysql_fetch_array($result))

I presume this is some kind of loop. Am I correct in assuming this loop is not working because there is no data to work with?

This shopping cart requires the linking of two tables in order to gather the data. I used the recordset feature from "dreamweaverMX" to generate the code necessary to extract data from two tables.
Both tables have data in them, but when I run this recordset I just get the field names with no data. Heres the code

SELECT cart.cartId, cart.cookieId, cart.itemId, cart.qty, dahlia_list.itemPrice, dahlia_list.itemId, dahlia_list.name
FROM cart, dahlia_list
WHERE cart.itemId=dahlia_list.itemId AND cart.cookieId='".GetCartId()."'
ORDER BY dahlia_list.name asc

If I can see the fields in the two databases, without error messages, then I presume half the battle is won. But I can't see the data in the fields.

I think I'm going wrong with

cart.cookieId='".GetCartId()."'

I have tried to customise this cart to my own web site, but this code is still used from the original code.

cart.cookieId='".GetCartId()."'

Is this the correct way to link a field from a database to a function?

If you can be bothered have a look at the code, it can be found here http://download.macromedia.com/pub/devnet/downloads/php_cart.zip

I've been pulling my hair out with frustration over this one.

Would be very grateful for any help.

Lloyd

    Write a Reply...