I keep getting these errors in my cart page where i display the items put in by the user.
these are the errors and the source code:
Warning: Undefined index: 4 in c:\Program Files\Apache Group\Apache/htdocs/tastywet/show_cart.php on line 18
Warning: Undefined variable: save in c:\Program Files\Apache Group\Apache/htdocs/tastywet/show_cart.php on line 26
Warning: Undefined variable: artist in c:\Program Files\Apache Group\Apache\htdocs\tastywet\output_func.php on line 349
Warning: Undefined variable: artist in c:\Program Files\Apache Group\Apache\htdocs\tastywet\output_func.php on line 350
$0.00
Warning: Undefined variable: artist in c:\Program Files\Apache Group\Apache\htdocs\tastywet\output_func.php on line 357
$0.00
Warning: Undefined variable: artist in c:\Program Files\Apache Group\Apache\htdocs\tastywet\output_func.php on line 349
Warning: Undefined variable: artist in c:\Program Files\Apache Group\Apache\htdocs\tastywet\output_func.php on line 350
show_cart.php
<?
include ("func.php");
// The shopping cart needs sessions, so start one
session_start();
if($new)
{
//new artist selected
if(!session_is_registered("cart"))
{
$cart = array();
session_register("cart");
$items = 0;
session_register("items");
$total_price = "0.00";
session_register("total_price");
}
if($cart[$new])//error is said to be here?
$cart[$new]++;
else
$cart[$new] = 1;
$total_price = calculate_price($cart);
$items = calculate_items($cart);
}
if($save)//error is said to be here?
{
foreach ($cart as $memberid => $qty)
{
if($$memberid=="0")
unset($cart[$memberid]);
else
$cart[$memberid] = $$memberid;
}
$total_price = calculate_price($cart);
$items = calculate_items($cart);
}
do_html_header("Artists selected for Hire");
if($cart&&array_count_values($cart))
display_cart($cart);
else
{
echo "<p>You have not selected any artists to hire.";
echo "<hr>";
}
$target = "index.php";
// if we have just added an artist to the cart, continue shopping in that category
if($new)
{
$details = get_artist_details($new);
if($details["Procatid"])
$target = "show_cat.php?procatid=".$details["Procatid"];
}
display_button($target, "continue-searching-for-artists", "Continue Searching For Artists");
$path = $PHP_SELF;
$path = str_replace("show_cart.php", "", $path);
display_button("https://".$SERVER_NAME.$path."checkout.php", "go-to-booking-selection", "Go To Booking Selection");
do_html_footer();
?>
output_func.php
function display_cart($cart, $change = true, $images = 1)
{
// display items in shopping cart
// optionally allow changes (true or false)
// optionally include images (1 - yes, 0 - no)
global $items;
global $total_price;
echo "<table border = 0 width = 100% cellspacing = 0>
<form action = show_cart.php method = post>
<tr><th colspan = ". (1+$images) ." bgcolor=\"#cccccc\">Artist(s)</th>
<th bgcolor=\"#cccccc\">Price</th><th bgcolor=\"#cccccc\">Quantity</th>
<th bgcolor=\"#cccccc\">Total</th></tr>";
//display each artist as a table row
foreach ($cart as $memberid => $qty)
{
$memberid = get_artist_details($memberid);
echo "<tr>";
if($images ==true)
{
echo "<td align = left>";
if (file_exists("images/$memberid.jpg"))
{
$size = GetImageSize("images/".$memberid.".jpg");
if($size[0]>0 && $size[1]>0)
{
echo "<img src=\"images/".$memberid.".jpg\" border=0 ";
echo "width = ". $size[0]/3 ." height = " .$size[1]/3 . ">";
}
}
else
echo " ";
echo "</td>";
}
echo "<td align = left>";
echo "<a href = \"show_artist.php?memberid=".$memberid."\">".$artist["stagename"];//error is said to be here
echo "</td><td align = center>$".number_format($artist["price"], 2);
echo "</td><td align = center>";
// if we allow changes, quantities are in text boxes
if ($change == true)
echo "<input type = text name = \"$memberid\" value = $qty size = 3>";
else
echo $qty;
echo "</td><td align = center>$".number_format($artist["price"]*$qty,2)."</td></tr>\n";
}
// display total row
echo "<tr>
<th colspan = ". (2+$images) ." bgcolor=\"#cccccc\"> </td>
<th align = center bgcolor=\"#cccccc\">
$items
</th>
<th align = center bgcolor=\"#cccccc\">
\$".number_format($total_price, 2).
"</th>
</tr>";
// display save change button
if($change == true)
{
echo "<tr>
<td colspan = ". (2+$images) ."> </td>
<td align = center>
<input type = hidden name = save value = true>
<input type = image src = \"images/save-changes.gif\"
border = 0 alt = \"Save Changes\">
</td>
<td> </td>
</tr>";
}
echo "</form></table>";
}
sorry for this massive post but i am really desperate! Ive been stuck for ages? could the problem be linked to my database because stupidly a named all of my indexes in the database in capitals not lowercase?
Can anyone see whats wrong?
thanks very much!