Jump to content

[SOLVED] Session problem


slibob

Recommended Posts

Hi

 

I have the following code:

 

<?php

include 'lib/config.php';
include 'lib/opendb.php';

$display_block = "";
$display_block2 = "";
$empty=0;

$sess_id = session_id();

$get_cart = "SELECT item_ref FROM shoppertrack WHERE userid = $sess_id";

$get_cart_res = mysql_query($get_cart) or die(mysql_error());

if(mysql_num_rows($get_cart_res) < 1)
{
$display_block2 = "<h1>You have no items in your cart. Please <a href=\"index.php\">continue to shop</a>!</p>";

} else {

while($cart=mysql_fetch_array($get_cart_res))
{

	$item_ref_cart = $cart[item_ref];

	$get_details = "SELECT item_title, item_desc, item_price FROM badges WHERE item_ref = $item_ref_cart";

	$get_details_res = mysql_query($get_details) or die(mysql_error());

	while($details=mysql_fetch_array($get_details_res))
	{

		$total_line = ($details[item_price])*($cart[item_qty]);
		$display_block.= "<tr><td>$item_ref_cart</td><td>$details[item_title]</td><td>$details[item_desc]</td><td>$details[item_price]</td><td>$cart[item_qty]</td><td>$total_line</td><td><a href=\"removeitem.php?id=$item_ref_cart\">x</a></td></tr>";
	}

}
}

?>
<html>
<head>
<title>Test</title>
</head>
<body>
<table align=center width=90%>
<tr><th>Ref</th><th>Title</th><th>Description</th><th>Price</th><th>Qty</th><th>Total</th><th></th></tr>

<? print $display_block2; ?>
<? print $display_block; ?>

</table>
</body>
</html>

 

... as showcart.php

 

I'm having trouble with the MySQL query on line 12 - I get the following error on execute:

 

Unknown column '843c484c51c42dcfc9e6fd392db3ecdc' in 'where clause'

 

... the long number being my session number

 

If you go to www.badgeshop.net, click 'buy' (to add something to the cart) the click Basket, you will (I hope) the same error.

 

I have tried the command straight on the MySQL prompt and I get exactly the same message.

 

Can anyone help?  The site is not a real shop, its some uni work, and I'm struggling!

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/41457-solved-session-problem/
Share on other sites

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.