0

hey ppl,
you helped me out allot of times, so i come back to you once again, i just transfered my website from a local pc(for testing) to a webserver @ my hosting.
now some parts arent working correctly.
some extra info about the page:
What kind of web page is it: Webshop
what was the server is tested it on: windows xp machine with xampp installed
what is the server where i get the errors: realy have no idea.

well here is my first problem:
when i add an item to my shopping cart everything goes fine and it looks like this:
http://img269.imageshack.us/img269/1344/afb1s.png
then i press on the shopping cart icon and i get the following error:
http://img824.imageshack.us/img824/3683/afb2.png
also when i add extra products it's not stored.

this all works well on the local machine but not there.
as you can see i get the following error:
Er staat 1 product in uw winkelwagen.

SELECT naam, prijs6, prijs12, prijs24 FROM wijnen WHERE id = ArrayUnknown column 'Array' in 'where clause'
in file /home/rb005851/public_html/cart.php on line 71
Productnaam Hoeveelheid Prijs p/s Totaal

translated for english ppl in here:
there is 1 product in your shopping cart.

SELECT name, price6, price12, price24 FROM wines WHERE id = ArrayUnknown column 'Array' in 'where clause'
in file /home/rb005851/public_html/cart.php on line 71
productname amouth price/piece total

here is the source code, hopefuly you can help me out here :)

<?php
// cart.php
session_start();
include "header.php";
?>
<br>
<br>
<br>
<?php
// Kijk of er iets in de winkelwagen zit
if (empty($_SESSION['cart'])) {
  echo "<p>Uw winkelwagen is leeg.</p>\n";
} else {
  // Exploden
  $cart = explode("|",$_SESSION['cart']);
  
  // Tellen inhoud winkelwagen
  $count = count($cart);
  if ($count == 1) {
    echo "<p>Er staat 1 product in uw winkelwagen.</p>\n";
  } else {
    echo "<p>Er staan ".$count." producten in uw winkelwagen</p>\n";
  }               // Ach, gewoon leuke mededeling
  
  // Wat javascriptjes voor het weghalen van producten
  // En daarna het begin van een tabel met de inhoud
  ?>
  <script type="text/javascript">
  <!--
  function removeItem(item) {
    var answer = confirm ('Weet u zeker dat u dit product wilt verwijderen?')
    if (answer)
    window.location="delete_cart_item.php?item=" + item;
  }

  function removeCart() {
    var answer = confirm ('Weet u zeker dat u de winkelwagen wilt leeghalen?')
    if (answer)
    window.location="delete_cart.php";
  }
  //-->
  </script>
  <form method="post" name="form" id="form" action="update_cart.php">
  <table>
    <tr>
      <td width="250"><b>Productnaam</b></td>
      <td width="150"><b>Hoeveelheid</b></td>
      <td width="150"><b>Prijs p/s</b></td>
      <td width="40"><b>Totaal</b></td>
      <td width="40">&nbsp;</td>
    </tr>
    <?php
  
    // Totaal (komt later wel terug)
    $total = 0;
	$i = 0;
    // Show cart
    foreach($cart as $products) {
      // Split
      /*
        $product[x] -->
           x == 0 -> product id
           x == 1 -> hoeveelheid
      */
      $product = explode(",",$products);
      // Get product info
      $sql = "SELECT naam, prijs6, prijs12, prijs24
             FROM wijnen
             WHERE id = ".$product[0];  
      $query = mysql_query($sql) or die (mysql_error()."<br>in file ".__FILE__." on line ".__LINE__);
      $pro_cart = mysql_fetch_object($query);
      $i++;

      echo "<tr>\n";

      echo "  <td>".$pro_cart->naam."</td>\n";     // naam
      echo "  <td><input type=\"hidden\" name=\"productnummer_".$i."\" value=\"".$product[0]."\" />\n"; // wat onzichtbare vars voor het updaten
      echo "      <input type=\"text\" onChange=\"document.getElementById('form').submit();\" name=\"hoeveelheid_".$i."\" value=\"".$product[1]."\" size=\"2\" maxlength=\"2\" /></td>\n";
	  if ($product[1] < 12){
      echo "  <td>€".$pro_cart->prijs6."</td>\n";
	  $lineprice = $product[1] * $pro_cart->prijs6;      // regelprijs uitrekenen > hoeveelheid * prijs
	  $lineprice = number_format($lineprice,2,".","");
	  }
	  elseif($product[1] <= 23){
	  echo "  <td>€".$pro_cart->prijs12."</td>\n";
	  $lineprice = $product[1] * $pro_cart->prijs12;      // regelprijs uitrekenen > hoeveelheid * prijs
	  $lineprice = number_format($lineprice,2,".","");
	  }
	  elseif($product[1] >= 23){
	  echo "  <td>€".$pro_cart->prijs24."</td>\n";
	  $lineprice = $product[1] * $pro_cart->prijs24;      // regelprijs uitrekenen > hoeveelheid * prijs
	  $lineprice = number_format($lineprice,2,".","");
	  }
      echo "  <td align='right'>€".$lineprice."</td>\n";
      echo "  <td align='right'><a href=\"javascript:removeItem(".$i.")\"><img src='images/delete.png' border='0'></td>\n"; // Verwijder, mooi plaatje van prullebak ofzo
      echo "</tr>\n";
	echo "<tr>";
      // Total
	  $total = $total + $lineprice;         // Totaal updaten
	  $total = number_format($total,2,".","");
    }
    ?>
	
	<hr width="755" align="left"></hr>
	<tr>
		<td></td><td></td>
		<td>
			<b>Verzendkosten</b>
		<td  align='right'>
			€5,95
		<?php
			$verzendkosten = number_format("5.95",2);
			$total = $total + $verzendkosten;
		?>
	</tr>
  <tr>
	<td><input type="hidden" name="totaal" value=<?php echo $total;?>></td>
	<td></td>
    <td><b>Totaal<b></td>
    <td  align='right'>€<?php echo $total; ?></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
    <td colspan="4"><a href="klantgegevenstemp.php?total=<?php echo $total;?>">Afrekenen</a></td>
  </tr>
  </table>
  </form>
  <?php
}
include "footer.php";
?>
2
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by thijscream
0

For some reason $product[0] contains an array, instead of a single value. Since you also state that more products are not handled correctly, I think the adding to the $cart is causing this problem.

I am not sure why you are using a pipe (|) as separator in it. You can just use $_SESSION as any other array.

0

sorry for the late delay, but how would you try to fix this?
still kinda new to this and i realy don't get why my xampp server supports everything but the hosting server does not... :S

0

btw i would like to add some extra info:

i added this:

echo '<pre>Inhoud $_SESSION[\'cart\']';
print_r($_SESSION['cart']);

when i try it on http://localhost/wijnkado/cart.php
i get the following:
with 1 product in cart:
Inhoud $_SESSION13,12
with 2 products in cart:
Inhoud $_SESSION13,12|57,12

and when i do this on http://kerstenswijnhandel.nl/cart.php
with 1 product in cart:
Inhoud $_SESSION13,12
with 2 products in cart or after refresh:
Inhoud $_SESSIONArray,|12,12

does anyone know how to fix this?

0

never mind, i found after 1 day searching what was the problem,
i changed the variable $cart to $cartz and that solved the problem.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.