Error 1064 in php call to mysql

06-24-08, 01:38 PM
|
|
Newbie Coder
|
|
Join Date: Jun 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Wow.
I can see how this works...the programming is still beyond my ability, but once I understand the logic it's only a matter of time until I get it.
That you were willing to take the time and help a newbie is very commendable. Thank you very much for taking the time to hand-hold me through this.
I have added code to Add One or Remove One from the cart, and a checkout, following the text. I'll need to figure out how to modify those so that they work with the multidimensional array.
Once I've mastered the basics, I hope to be a useful contributor here.  There is a lot to learn on these pages.
One more chapter in the book and I'll turn my focus on creating databases and pages for my Firebird website, which is why I wanted to learn this in the first place.
|

06-24-08, 08:05 PM
|
 |
Community Liaison
|
|
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
|
|
Quote:
Originally Posted by Vikki
Wow.
I can see how this works...the programming is still beyond my ability, but once I understand the logic it's only a matter of time until I get it.
That you were willing to take the time and help a newbie is very commendable. Thank you very much for taking the time to hand-hold me through this.
I have added code to Add One or Remove One from the cart, and a checkout, following the text. I'll need to figure out how to modify those so that they work with the multidimensional array.
Once I've mastered the basics, I hope to be a useful contributor here.  There is a lot to learn on these pages.
One more chapter in the book and I'll turn my focus on creating databases and pages for my Firebird website, which is why I wanted to learn this in the first place.
|
I started this so I took it as a challenge. And I appreciate your complement.
The multi-demensional array I created is simply a table with rows (records) and columns (fields that hold the values).
So $this->Orders[0][0] would be record 0 column 0.
And $this->Orders[0][1] would be record 0 column 1.
And $this->Orders[0][2] would be record 0 column 2.
And $this->Orders[1][0] would be record 1 column 0.
And $this->Orders[1][1] would be record 1 column 1.
And $this->Orders[1][2] would be record 1 column 2.
And so forth...
You just add another column to store the quantity that can be used with each record independently.
Add in the logic for an input field and your all set.
At checkout you just read the $this->Orders array and extract only the ones that have a value.
__________________
Jerry Broughton
|

06-24-08, 10:27 PM
|
 |
Community Liaison
|
|
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
|
|
This is a revised version of ShoppingCart.php with all the junk removed.
ShoppingCart.php
__________________
Jerry Broughton
|

06-25-08, 10:52 PM
|
 |
-
|
|
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
|
|
This loop
could be written like so:
Both approaches are valid and equivalent.
|

04-20-09, 02:11 AM
|
|
New Member
|
|
Join Date: Apr 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
Still need help, can figure out the problem!
Currently taking off post.
Working on code at the moment. Will repost again soon.
Last edited by jaimenacach; 04-20-09 at 02:23 AM.
|

04-22-09, 05:39 PM
|
|
New Member
|
|
Join Date: Apr 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Cody by job0107 Works! I've confirmed it
Hi, I'm new to the forum,
I have had the exact same issue as Vikki had, with every same EXACT problem throughout her posts.
I've taken the code from ShoppingCart.php in Post #23 by Job0107 and replaced it in my Shoppingcart.php. The shopping cart now works perfeclty. You can add items from any category, at any time, and the shopping cart ADDs them perfectly!
Thanks so much for the information you provided job0107!
I'm new to PHP programming too, and also have taken this challenge on my own, as I'm not part of any class, and don't get a grade!
It's too bad the author of our text book (Gosselin) did not review his code before printing his book. There are several errors.
In any case, if anyone needs the entire code from the various pages. Here they are. They are the pages that one creates for you Chapter Directory for Chapter 11 for the book called "PHP Programming with MySQL" by Don Gosselin.
Good luck to all the new students in the future!
ShoppingCart.php
ShowCart.php
GosselingGourmetCoffee.php
thanks so much once again
Jaime Nacach

|

04-22-09, 06:27 PM
|
|
New Member
|
|
Join Date: Apr 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
Cant figure out some notation in PHP
Hello,
I would like to know if someone can explain to me some of the code that user "job0107" used for declaring some variables from post #23. Part of it is shown below. It's part of the code for the function called showCart() within the ShoppingCart Class on ShoppingCart.php.
I don't understand how the following declarations works, or what they mean. How is the notation $ProdID = $Order[0] ? $Order[0] : ""; read, or what does it mean?
What does the "?" and the ":" represent?
I've tried searching for the meaning online. But can't find anything, or just don't know how to Google for it.
I know that the way it's written WORKS properly and that the variables do print out the correct TABLE name and product ID. I just want to know why.
Once the multidimensional array $Orders is broken down,
Why can't we just declare the following:
$Table_Name = $Order[1];
$ProdID = $Order[0];
Thanks for the help!
Jaime Nacach
Last edited by jaimenacach; 04-22-09 at 06:31 PM.
|

04-30-09, 12:20 AM
|
|
Aspiring Coder
|
|
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
|
|
Quote:
|
I don't understand how the following declarations works, or what they mean. How is the notation $ProdID = $Order[0] ? $Order[0] : ""; read, or what does it mean?
|
This is just an easy and fast way to write an if/else statement. Syntax is as follows
($argument) ? 'true' : 'false';
So,
|

04-30-09, 12:15 PM
|
|
New Member
|
|
Join Date: Apr 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thank you so much for the answer....
that's very helpful!
I knew I had seen it somewhere, but could not reference back to it. Thanks for the post.
|

04-30-09, 12:49 PM
|
 |
Community Liaison
|
|
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
|
|
Quote:
Originally Posted by jaimenacach
Thank you so much for the answer....
that's very helpful!
I knew I had seen it somewhere, but could not reference back to it. Thanks for the post.
|
The other reason to use Boolean logic or an if/else statement is so the variable gets initialized whether the array element exists or not.
In some instances if the variable is not initialized before it is used, then a caution! warning will be generated.
It's always good practice to initialize your variables either with a value or null.
__________________
Jerry Broughton
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|