Jump to content

Shopping cart Addtobasket


jkewlo

Recommended Posts

hey i think i have hit a dead end in the road i can see the area i need to go but need help turning around..

 

kk on the add_tobasket.php

 

i need to take the data from the previous page by the id i have the id called

 

id=4 for instance.

 

well i need to add it to a table called Cart.

 

i can display the data telling the user Now Adding Item into the Database

 

then show the items.

 

now do i need to have a insert into statement insert it on the same page?

 

 

Getting the data

<?
	  
	//$url is asking the url master.php?id= for what id= what id= is hardcoded into the links General_Art etc... 

	$url = $_REQUEST["id"];

$conn = new COM('ADODB.Connection') or die('Could not make conn');
$rs = new COM('ADODB.Recordset') or die('Coult not make rs');

$connstring = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\\wamp\\www\\pro\\project\\Rainwater.mdb";

$conn->Open($connstring);
if (!$conn)
  {exit("Connection Failed: " . $conn);}
$sql="SELECT * 
FROM Books 
WHERE Product_id = '". $url ."'";
$rs->Open($sql, $conn);

?>

 

Insert Data

<?php
$url = $_REQUEST["id"];
$count++;	
$Itemname = $rs->Fields[Title];
$ItemId = $rs->Fields[Product_ID];
$Price = $rs->Fields['Price'];
$Time = date(time());
$Date = date("d/m/y : H:i:s");
$Small = $rs->Fields['Small'];
$conn = new COM('ADODB.Connection') or die('Could not make conn');
$rs = new COM('ADODB.Recordset') or die('Coult not make rs');

$connstring = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\\wamp\\www\\pro\\project\\Rainwater.mdb";

$conn->Open($connstring);
if (!$conn)
  {exit("Connection Failed: " . $conn);}

$sql = "INSERT INTO Cart (Username, Count, ItemName, ItemID, Price, Time, Date, Small) 
VALUES ('$username', '$count', '$Itemname', '$ItemID', '$price', '$time', '$Date', 'Small')";
$rs->Open($sql, $conn);

?>

 

just wondering if this was possible.

cuz i keep getting the error

 

Catchable fatal error: Object of class variant could not be converted to string in C:\wamp\www\pro\project\add_tobasket.php on line 196

 

Line 196 is the Insert Into Statement Value

Link to comment
https://forums.phpfreaks.com/topic/97266-shopping-cart-addtobasket/
Share on other sites

after a very quick look

 

please read comments

 

<?php
$Itemname = $rs->Fields[Title]; //Constant ? or should it be 'Title'
$ItemId = $rs->Fields[Product_ID]; //Constant  or should it be 'Product_ID'
$Price = $rs->Fields['Price'];
$Time = date(time());
$Date = date("d/m/y : H:i:s");
$Small = $rs->Fields['Small'];

//$username isn't set at all!
//$ItemID isn't set but $ItemId is
//$price isn't set but $Price is
//$time isn't set but $Time is
$sql = "INSERT INTO Cart (Username, Count, ItemName, ItemID, Price, Time, Date, Small) 
VALUES ('$username', '$count', '$Itemname', '$ItemID', '$price', '$time', '$Date', 'Small')";
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.