|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I'm trying to get the shoppingcart from the tutorial on this site to work.
I've modified it a bit, and now I'm stuck. Been running around in circles to try and find out the error. I've searched and read all the posts about this particular tutorial on the forum, but only found one other mention of the same error, and no solution. Here's the walkthrough: The page products.php includes a db.inc with databaseinfo, and a function: (the database was already in place, with norwegian titles, therefore I've changed them in the scripts (ie: cartId = handlekurvID) [From dp.inc (also called dp.php in the tutorial. got an error when i called it that) ] PHP Code:
heres the products.php: PHP Code:
Here's the cart.php: PHP Code:
Finally - showcart.php PHP Code:
------------------------ THere you have the whole thing. Hope someone's got their kind suit on today, and is willing to help a php-newbie. This has gotten me on the verge of mental meltdown the past two days. Here's what happens. The products.php shows my products without problem When I press "add item", this show up: Query failed: You have an error in your SQL syntax near '' at line 1 Thanks for reading this, deeply grateful for any help... |
|
#2
|
|||
|
|||
|
Duckman,
What you should try is first storing your SQL query in a variable, and then echo out the variable value to see exactly what MySQL is receiving... It may be something in your query string. I'm not completely sure, but I have a feeling it may have something to do with this part of your query: PHP Code:
You're using single quotes... Is the value of "GetCardId()" a string value or an integer? If it's not a string, that would cause an error. PS: When you post code, please try to use the [ php ] and [/ php ] BB codes (no spaces between the contents and the square braces). It makes for much easier reading of your code!
__________________
____________________________________________ Developer Shed Weekly Writer | DevArticles Forum Moderator Build Your Own KlipFolio Klip With PHP FrankManno.com - Under Construction Design Interactive Group - Under Construction |
|
#3
|
|||
|
|||
|
Quote:
Hi FrankieShakes, thanks for giving this a shot ![]() the sql-snippet you mention is where I also belive the error lies. PHP Code:
That calls the function "GetCartId" from db.inc. That function - GetCartId is this one: It returns a string. PHP Code:
Sorry for leaving the [ php] [/ php] out, but I see someone already has edited my post while I slept. I'll behave from now on ![]() |
|
#4
|
|||
|
|||
|
FrankieShakes, tried what you said - about putting the query in a string to see what happened.
Put it on the line before the one I suspect makes the error: PHP Code:
Here's the result : Select count(*) from handlekurv where cookieID = '382c5c2d7275d80a89d5a07c1de6a4d7' and produktID = Query failed: You have an error in your SQL syntax near '' at line 1 |
|
#5
|
|||
|
|||
|
Okay!
I think I got it... PHP Code:
Should be: PHP Code:
You weren't using the superglobal array ($_GET) to retrieve the value of produktID. As you can see by the echoed query, "... and produktID = ". There was no value for produktID. HTH! |
|
#6
|
|||
|
|||
|
Quote:
And it WORKS ![]() Thanks a lot, FrankieShakes! I can sleep at night now. The only thing to find out, is why my cart.php/showcart.php does NOT show any products ![]() But that's been asked a million times here, I noticed when I searched for answers to this question. So I'll try those solutions before I pester anyone again! |
|
#7
|
|||
|
|||
|
No problem, Duckman!
Any updated on the no showing of products? Any luck on finding a fix in the forums? |
|
#8
|
|||
|
|||
|
How about a checkout script?
How about a checkout script? For the same tutorial?
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Another ShoppingCartTutorial question. heeeeelp!! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|