I am very new to PHP and server side languages - I am building a shopping cart system. I use one table for most products but some products change pirices for size color etc so for those products I built a seperate table with a id that correlated to the main table and but also has a unique id.
the page before sends the item number, color, qty, price if it from the main table otherwise it just sends the id and the qty.
so I am trying to get it to to grab the products from the other table "multiple" then check to see if that is empty if so just to fil out the user_track table with the supplied variables else I have to get teh variables then insert them,
I thought this would work but no matter what I keep getting a error:
Parse error: parse error, expecting STRING' orNUM_STRING' or `'$'' in web/addtocart.php3 on line 1
<?
// set cookie if not already set
if (!isset($userid)) {
$token = md5(uniqid(rand()));
setcookie("user_id", $token, time()+86400, "/", ".domain.com");
}
$connection = mysql_connect("localhost", "user", "password")
or die ("Couldn't connect to server.");
$db = mysql_select_db("db", $connection)
or die ("Couldn't select database.");
$date_added = date("Y-m-d");
if ($sel_item_special == "") {
$sel_item_totalprice = $sel_item_qty * $sel_item_price;
$sql = "INSERT INTO roomsinbloom.user_track VALUES
(\"$user_id\", \"$sel_item\", \"$sel_item_name\", \"$sel_item_color\", \"$sel_item_qty\",
\"$sel_item_special\", \"$sel_item_price\", \"$sel_item_totalprice\", \"$date_added\")";
$sql_result = mysql_query($sql, $connection) or die ("couldnt insert record");
$item_count = "SELECT SUM(sel_item_qty) FROM user_track WHERE user_id = \"$user_id\"";
} else {
$query = "SELECT * FROM multiple WHERE unique_id = \"$sel_item_special\"";
$query_results = mysql_query($query, $connection) or die ("couldn't get result");
$row2 = mysql_fetch_array($query_results);
$sel_item2 = $row["unique_id'];
$sel_item_name2 = $row["name2"];
$sel_item_color2 = $row["color2"];
$sel_item_price2 = $row["price2"];
$sel_item_totalprice2 = $sel_item_qty * $sel_item_price2;
$sql = "INSERT INTO user_track VALUES
(\"$user_id\", \"$sel_item2\", \"$sel_item_name2\", \"$sel_item_color2\", \"$sel_item_qty\",
\"$sel_item_special\", \"$sel_item_price2\", \"$sel_item_totalprice2\", \"$date_added\")";
$sql_result = mysql_query($sql, $connection) or die ("couldnt insert record");
$item_count = "SELECT SUM(sel_item_qty) FROM user_track WHERE user_id = \"$user_id\"";
}
$item_result = mysql_query($item_count);
$item_count_total = mysql_result($item_result, 0, "SUM(sel_item_qty)");
?>