Thanks for the help but this hasn’t worked it returns the error:
Warning: mysql_real_escape_string() expects parameter 1 to be string, resource given in /home/—/public_html/—/store_basket.php on line 30
Warning: mysql_real_escape_string() expects parameter 1 to be string, resource given in /home/—/public_html/—/store_basket.php on line 32
0 Items - £0.00 Check Out
I should post my whole page contents which are:
<?php
session_start();
include("dbstore.php");
$storeurl = addslashes($_GET['url']);
$productid = addslashes($_GET['id']);
$getstore = mysql_query("SELECT * FROM `store` WHERE `url` = '$storeurl'") or die(mysql_error());
$store = mysql_fetch_array($getstore);
// Grab shopping cart session if it exists
if(isset($_SESSION['cart_id_set'])) {
$getbasket = mysql_query("SELECT * FROM `store_basket` WHERE `id` = '".$_SESSION['cart_id']."'") or die(mysql_error());
$basket = mysql_fetch_assoc($getbasket);
echo"I'm basket ".$_SESSION['cart_id'];
// Create shopping cart session if it does not exist yet..
} else {
$current2 = time(); //Current timestamp
$countcarts = mysql_query("SELECT MAX(id) FROM `store_basket`") or die(mysql_error());
$newcartid = $countcarts++;
$createcart = mysql_query("INSERT INTO `store_basket` (`id`, `timestamp`) VALUES('" . mysql_real_escape_string($newcartid) . "', '" . $current2 . "')") or die(mysql_error());
$getbasketid = mysql_query("SELECT * FROM `store_basket` WHERE `id` = '" . mysql_real_escape_string($newcartid) . "'") or die(mysql_error());
$basketid = mysql_fetch_array($getbasketid);
$sessionvalue = $basketid['id'];
$_SESSION['cart_id'] = $sessionvalue;
$_SESSION['cart_id_set'] = 'yes';
}
if(isset($_GET['addtocart'])) {
echo"<div id=\\"basket\\">0 Items - £0.00 <u>Check Out</u></div>";
}
else {
echo"<div id=\\"basket\\">0 Items - £0.00 <u>Check Out</u></div>";
}
?>