General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 21st, 2004, 05:33 AM
chris9902 chris9902 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 3 chris9902 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Shopping cart

i have been trying to use THIS

it is easy to follow but the code does not work,

this is my db.php file

PHP Code:
<?php

// This page contains the connection routine for the
// database as well as getting the ID of the cart, etc

$dbServer "localhost";
$dbUser "root";
$dbPass "password";
$dbName "cart";

function 
ConnectToDb($server$user$pass$database)
{
// Connect to the database and return
// true/false depending on whether or
// not a connection could be made.

$s = @mysql_connect($server$user$pass);
$d = @mysql_select_db($database$s);

if(!
$s || !$d)
return 
false;
else
return 
true;
}

function 
GetCartId()
{
// This function will generate an encrypted string and
// will set it as a cookie using set_cookie. This will
// also be used as the cookieId field in the cart table

if(isset($_COOKIE["cartId"]))
{
return 
$_COOKIE["cartId"];
}
else
{
// There is no cookie set. We will set the cookie
// and return the value of the users session ID

session_start();
setcookie("cartId"session_id(), time() + ((3600 24) * 30));
return 
session_id();
}
}

?>


and this is my products.php page.

PHP Code:
<?php 

// This page will list all of the items
// from the items table. Each item will have
// a link to add it to the cart

include("db.php"); 

// Get a connection to the database
$cxn = @ConnectToDb($dbServer$dbUser$dbPass$dbName); 
$result mysql_query("select * from items order by itemName asc"); 
?>

<?php 
while($row mysql_fetch_array($result)) 

?> 
<tr>
<td width="30%" height="25">
<font face="verdana" size="1" color="black">
<?php echo $row["itemName"]; ?> 
</font>
</td>
<td width="10%" height="25">
<font face="verdana" size="1" color="black">
<?php echo $row["itemPrice"]; ?> 
</font>
</td>
<td width="50%" height="25">
<font face="verdana" size="1" color="black">
<?php echo $row["itemDesc"]; ?> 
</font>
</td>
<td width="10%" height="25">
<font face="verdana" size="1" color="black">
<a href="cart.php?action=add_item&id=<?php echo $row["itemId"]; ?>&qty=1">Add Item</a>
</font>
</td>
</tr>
<tr>
<td width="100%" colspan="4">
<hr size="1" color="red" NOSHADE>
</td>
</tr>
<tr>
<td width="100%" colspan="4">
<font face="verdana" size="1" color="black">
<a href="cart.php">Your Shopping Cart >></a>
</font>
</font>
</td>
</tr>
<?php ?>
</table>
</body>
</html>


i added all the info to the database using PHPmyAdmin.

does anyone have a working version of this script or a better tutorial link.

Thank you

Reply With Quote
  #2  
Old January 21st, 2004, 08:33 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
What doesn't work about the code?

Reply With Quote
  #3  
Old January 21st, 2004, 08:40 AM
chris9902 chris9902 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 3 chris9902 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
it does not display like the picture that person posted

Reply With Quote
  #4  
Old January 21st, 2004, 10:09 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
What does display?
do yo uget an error at all?

Reply With Quote
  #5  
Old January 21st, 2004, 10:15 AM
chris9902 chris9902 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 3 chris9902 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
no, all i see id the work add item

Reply With Quote
  #6  
Old January 21st, 2004, 07:53 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Chris,

It's odd that you say it doesn't work... I haven't had any problems running it on my system.

Would you mind posting a screenshot of how it's displaying for you. I have a feeling it may be something simple in the code.

Thanks.

Reply With Quote
  #7  
Old January 27th, 2004, 07:35 AM
davidekins davidekins is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 9 davidekins User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 54 m 31 sec
Reputation Power: 0
Shopping Cart

Has anyone got a working version of the scripts from the original article i.e.

Cart.php
db.php
products.php

I have tried using the content from the original article but must be missing some of the info as I cannot get it to work properly.

Be much appreciated

Regards

David

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Shopping cart


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT