I've found a bunch of errors in the code and have resolved them.
The updated code:
<?php
session_start();
header("Cache-control:private");
error_reporting(E_ALL);
include("dblogin.php");
include("showerror.php");
$custID = $_SESSION['custID'];
/* $sql = "INSERT INTO cart (cartID, cartCustID, cartItemID, qty, cost) VALUES (0, '$custID', '$itemToAdd', 1, '$cost')";
$query = mysql_query($sql);
if($query) {
header("Location:cart.php");
} else {
echo("<h3>There's something wrong.</h3>");
showerror();
} */
$sql1 = "SELECT * FROM cart WHERE cartCustID = '$custID'";
$query1 = mysql_query($sql1);
while($row1 = mysql_fetch_array($query1)) {
if($row1['cartItemID'] == $itemToAdd) {
$itemToAdd = $_GET['movieID'];
$cost = $_GET['cost'];
$sql2 = "UPDATE cart SET qty = qty + 1";
$query2 = mysql_query($sql2);
mysql_select_db($dbname, $connection);
if($query2) {
header("Location:cart.php");
} else {
echo("<h3>There's something wrong!,</h3>");
showerror();
}
} else {
$sql3 = "INSERT INTO cart (cartID, cartCustID, CartItemID, qty, cost) VALUES (0, '$custID', '$itemToAdd', 1, '$cost')";
$query3 = mysql_query($sql3);
mysql_select_db($dbname, $connection);
if($query3) {
header("Location:cart.php");
} else {
echo("<h3>There's something wrong!</h3>");
showerror();
}
}
}
?>
It seems to trip up on:
while($row1 = mysql_fetch_array($query1)) {
Don't know why. That just seems to be where the script stops working. The commented out script above the main script is a working, much simpler version, but it doesn't do what I need it to do.