[PHP] Shopping Cart

2009-05-16 Thread Vernon St Croix
Hi,

I am pretty new to PHP and I am trying to create a shopping cart. 

I keep on getting the below error when trying to show the shopping list. 

Any guidance that can be provided will be very much appreciated

Fatal error: Call to a member function query() on a non-object in 
C:\wamp\www\draft\basket.php on line 36

mysql_connect.php


basket.php

 
Rum Basket

 

  Rum on Offer
  query($sql);
 $output[]= '';
 while ($row = $result->fetch()) {
 $output[] = ''.$row['name'].': £'.$row['price'].'Add to Cart';
}
$output[] = '';
  echo join ('', $output);
   ?>
  





cart.php

$value) {
   if (stristr($key,'qty')) {
$id = str_replace('qty','',$key);
$items = ($newcart != '') ? explode(',',$newcart) : explode(',',$cart);
$newcart = '';
foreach ($items as $item) {
 if ($id != $item) {
  if ($newcart != '') {
   $newcart .= ','.$item;
  } else {
   $newcart = $item;
  }
 }
}
for ($i=1;$i<=$value;$i++) {
 if ($newcart != '') {
  $newcart .= ','.$id;
 } else {
  $newcart = $id;
 }
}
   }
  }
 }
 $cart = $newcart;
 break;
}
$_SESSION['cart'] = $cart;

?>



Rum Basket







Please Check Quantities...



Back to Rum List








functions.php

There is no alcohol in your Rum Basket';
 } else {
  // Parse the cart session variable
  $items = explode(',',$cart);
  $s = (count($items) > 1) ? 's':'';
  return 'There are'.count($items).' item'.$s.' in your 
rum basket';
 }
}
  
 function showCart() {
 $cart = $_SESSION['cart'];
 if ($cart) {
  $items = explode(',',$cart);
  $contents = array();
  foreach ($items as $item) {
   $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1;
  }
  $output[] = '';
  $output[] = '';
  foreach ($contents as $id=>$qty) {
   $sql = 'SELECT * FROM spirits WHERE id = '.$id;
   $result = $con->query($sql);
   $row = $result->fetch();
   extract($row);
   $output[] = '';
   $output[] = 'Remove';
   $output[] = ''.$name.'';
   $output[] = '£'.$price.'';
   $output[] = '';
   $output[] = '£'.($price * $qty).'';
   $total += $price * $qty;
   $output[] = '';
  }
  $output[] = '';
  $output[] = 'Grand total: £'.$total.'';
  $output[] = 'Update cart';
  $output[] = '';
 } else {
  $output[] = 'You shopping cart is empty.';
 }
 return join('',$output);
}

?>




Many Thanks

Vee

[PHP] Check out system for Shopping Cart

2009-05-21 Thread Vernon St . Croix


Can you please help with my checkout script. I have been getting errors as 
shown below:

Warning:  mysqli_query() expects parameter 1 to be mysqli, object given in 
C:\wamp\www\draft\checkout.php on line 26



Warning:  mysqli_affected_rows() expects parameter 1 to be mysqli, object given 
in C:\wamp\www\draft\checkout.php on line 28



Warning:  mysqli_rollback() expects parameter 1 to be mysqli, object given in 
C:\wamp\www\draft\checkout.php on line 77

System error

Warning:  mysqli_close() expects parameter 1 to be mysqli, object given in 
C:\wamp\www\draft\checkout.php on line 83

for the script

 $item){

$qty = $item['quantity'];
$price = $item['price'];

mysqli_stmt_execute($stmt);

$affected += mysqli_stmt_affected_rows($stmt);

}

mysqli_stmt_close($stmt);

if ($affected ==count($_SESSION['cart'])) {

mysqli_commit($con);

echo'Thank you for your order';

}else{

mysqli_rollback($con);

echo'Your order could not be processed';

}

}else{

mysqli_rollback($con);

echo'System error';

}

mysqli_close($con);



include ("footer.html");


?>

Many Thanks




VEE
VEE



_
View your Twitter and Flickr updates from one place – Learn more!
http://clk.atdmt.com/UKM/go/137984870/direct/01/-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] Display Image

2009-05-25 Thread Vernon St . Croix

I am trying to send images to my browser using the header function, but keep on 
getting 'No image Available'.

Can someone please help!!
_
View your Twitter and Flickr updates from one place – Learn more!
http://clk.atdmt.com/UKM/go/137984870/direct/01/-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php