Menu
Coz when i run it it have a Parse error: parse error, unexpected $end in c:appservwwwwhole27copy changedoutput_fns.php on line 443
i know this error is so unbelieveable to u but help me ….PlZZZZZZZZZZZ………..
[code=php]<?php
function do_html_header($title = '')
{
// print an HTML header
// declare the session variables we want access to inside the function
if(!$_SESSION['items']) $_SESSION['items'] = '0';
if(!$_SESSION['total_price']) $_SESSION['total_price'] = '0.00';
}
?>
<html>
<head>
<title><?php echo $title; ?></title>
<style>
h2 { font-family: Arial, Helvetica, sans-serif; font-size: 22px; color = red; margin = 6px }
body { font-family: Arial, Helvetica, sans-serif; font-size: 13px }
li, td { font-family: Arial, Helvetica, sans-serif; font-size: 13px }
hr { color: #FF0000; width=70%; text-align=center}
a { color: #000000 }
</style>
</head>
<body>
<table width='100%' border=0 cellspacing = 0 bgcolor='#cccccc'>
<tr>
<td rowspan = 2>
<a href = 'index.php'><img src='images/Book-O-Rama.gif' alt='Bookorama' border=0
align='left' valign='bottom' height = 55 width = 325></a>
</td>
<td align = 'right' valign = 'bottom'>
<?php if(isset($_SESSION['admin_user']))
echo ' ';
else
echo 'Total Items = '.$_SESSION['items'];
?>
</td>
<td align = 'right' rowspan = 2 width = 135>
<?php if(isset($_SESSION['admin_user']))
display_button('logout.php', 'log-out', 'Log Out');
else
display_button('show_cart.php', 'view-cart', 'View Your Shopping Cart');
?>
</tr>
<tr>
<td align = right valign = top>
<?php if(isset($_SESSION['admin_user']))
echo ' ';
else
echo 'Total Price = $'.number_format($_SESSION['total_price'],2);
?>
</td>
</tr>
</table>
<?php
if($product_name){
do_html_heading($product_name);
}
function do_html_footer()
{
// print an HTML footer
?>
</body>
</html>
<?php
}
function do_html_heading($heading)
{
// print heading
?>
<h2><?php echo $heading; ?></h2>
<?php
}
function do_html_URL($url, $name)
{
// output URL as link and br
?>
<a href="<?php echo $url; ?>"><?php echo $name; ?></a><br />
<?php
}
function display_categories($cat_array)
{
if (!is_array($cat_array))
{
echo 'No categories currently available<br />';
return;
}
echo '<ul>';
foreach ($cat_array as $row)
{
$url = 'show_cat.php?cat_id='.($row['cat_id']);
$title = $row['cat_name'];
echo '<li>';
do_html_url($url, $title);
echo '</li>';
}
echo '</ul>';
echo '<hr />';
}
function display_books($book_array)
{
//display all books in the array passed in
if (!is_array($book_array))
{
echo '<br />No books currently available in this category<br />';
}
else
{
//create table
echo '<table width = "100%" border = 0>';
//create a table row for each book
foreach ($book_array as $row)
{
$url = 'show_book.php?product_id='.($row['product_id']);
echo '<tr><td>';
if (@file_exists('images/'.$row['product_id'].'.jpg'))
{
$title = '<img src='images/'.($row['product_id']).'.jpg' border=0 />';
do_html_url($url, $title);
}
else
{
echo ' ';
}
echo '</td><td>';
$title = $row['product_name'].' by '.$row['product_id'];
do_html_url($url, $title);
echo '</td></tr>';
}
echo '</table>';
}
echo '<hr />';
}
function display_book_details($product)
{
// display all details about this book
if (is_array($product))
{
echo '<table><tr>';
//display the picture if there is one
if (@file_exists('images/'.($product['product_id']).'.jpg'))
{
$size = GetImageSize('images/'.$product['product_id'].'.jpg');
if($size[0]>0 && $size[1]>0)
echo '<td><img src='images/'.$product['product_id'].'.jpg' border=0 '.$size[3].'></td>';
}
echo '<td><ul>';
echo '<li><b>Product Name:</b> ';
echo $product['product_name'];
echo '</li><li><b>Product Id:</b> ';
echo $product['product_id'];
echo '</li><li><b>Our Price:</b> ';
echo number_format($product['price'], 2);
echo '</li><li><b>Description:</b> ';
echo $product['description'];
echo '</li></ul></td></tr></table>';
}
else
echo 'The details of this product cannot be displayed at this time.';
echo '<hr />';
}
function display_checkout_form()
{
//display the form that asks for name and address
?>
<br />
<table border = 0 width = '100%' cellspacing = 0>
<form action = 'purchase.php' method = 'post'>
<tr><th colspan = 2 bgcolor='#cccccc'>Your Details</th></tr>
<tr>
<td>Name</td>
<td><input type = 'text' name = 'name' value = "" maxlength = 40 size = 40></td>
</tr>
<tr>
<td>Address</td>
<td><input type = 'text' name = 'address' value = "" maxlength = 40 size = 40></td>
</tr>
<tr>
<td>City/Suburb</td>
<td><input type = 'text' name = 'city' value = "" maxlength = 20 size = 40></td>
</tr>
<tr>
<td>State/Province</td>
<td><input type = 'text' name = 'state' value = "" maxlength = 20 size = 40></td>
</tr>
<tr>
<td>Postal Code or Zip Code</td>
<td><input type = 'text' name = 'zip' value = "" maxlength = 10 size = 40></td>
</tr>
<tr>
<td>Country</td>
<td><input type = 'text' name = 'country' value = "" maxlength = 20 size = 40></td>
</tr>
<tr><th colspan = 2 bgcolor='#cccccc'>Shipping Address (leave blank if as above)</th></tr>
<tr>
<td>Name</td>
<td><input type = 'text' name = 'ship_name' value = "" maxlength = 40 size = 40></td>
</tr>
<tr>
<td>Address</td>
<td><input type = 'text' name = 'ship_address' value = "" maxlength = 40 size = 40></td>
</tr>
<tr>
<td>City/Suburb</td>
<td><input type = 'text' name = 'ship_city' value = "" maxlength = 20 size = 40></td>
</tr>
<tr>
<td>State/Province</td>
<td><input type = 'text' name = 'ship_state' value = "" maxlength = 20 size = 40></td>
</tr>
<tr>
<td>Postal Code or Zip Code</td>
<td><input type = 'text' name = 'ship_zip' value = "" maxlength = 10 size = 40></td>
</tr>
<tr>
<td>Country</td>
<td><input type = 'text' name = 'ship_country' value = "" maxlength = 20 size = 40></td>
</tr>
<tr>
<td colspan = 2 align = 'center'>
<b>Please press Purchase to confirm your purchase,
or Continue Shopping to add or remove items</b>
<?php display_form_button('purchase', 'Purchase These Items'); ?>
</td>
</tr>
</form>
</table><hr />
<?php
}
[/code]
[code=php]
function display_shipping($shipping)
{
// display table row with shipping cost and total price including shipping
?>
<table border = 0 width = '100%' cellspacing = 0>
<tr><td align = 'left'>Shipping</td>
<td align = 'right'> <?php echo number_format($shipping, 2); ?></td></tr>
<tr><th bgcolor='#cccccc' align = 'left'>TOTAL INCLUDING SHIPPING</th>
<th bgcolor='#cccccc' align = 'right'>$<?php echo number_format($shipping+$_SESSION['total_price'], 2); ?></th>
</tr>
</table><br />
<?php
}
function display_card_form($name)
{
//display form asking for credit card details
?>
<table border = 0 width = '100%' cellspacing = 0>
<form action = 'process.php' method = 'post'>
<tr><th colspan = 2 bgcolor="#cccccc">Credit Card Details</th></tr>
<tr>
<td>Type</td>
<td><select name = 'card_type'><option>VISA<option>MasterCard<option>American Express</select></td>
</tr>
<tr>
<td>Number</td>
<td><input type = 'text' name = 'card_number' value = "" maxlength = 16 size = 40></td>
</tr>
<tr>
<td>AMEX code (if required)</td>
<td><input type = 'text' name = 'amex_code' value = "" maxlength = 4 size = 4></td>
</tr>
<tr>
<td>Expiry Date</td>
<td>Month <select name = 'card_month'><option>01<option>02<option>03<option>04<option>05<option>06<option>07<option>08<option>09<option>10<option>11<option>12</select>
Year <select name = 'card_year'><option>00<option>01<option>02<option>03<option>04<option>05<option>06<option>07<option>08<option>09<option>10</select></td>
</tr>
<tr>
<td>Name on Card</td>
<td><input type = 'text' name = 'card_name' value = "<?php echo $name; ?>" maxlength = 40 size = 40></td>
</tr>
<tr>
<td colspan = 2 align = 'center'>
<b>Please press Purchase to confirm your purchase,
or Continue Shopping to add or remove items</b>
<?php display_form_button('purchase', 'Purchase These Items'); ?>
</td>
</tr>
</table>
<?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)
echo '<table border = 0 width = "100%" cellspacing = 0>
<form action = "show_cart.php" method = "post">
<tr><th colspan = '. (1+$images) .' bgcolor="#cccccc">Item</th>
<th bgcolor="#cccccc">Price</th><th bgcolor="#cccccc">Quantity</th>
<th bgcolor="#cccccc">Total</th></tr>';
//display each item as a table row
foreach ($cart as $product_id => $qty)
{
$product = get_book_details($product_id);
echo '<tr>';
if($images ==true)
{
echo '<td align = left>';
if (file_exists("images/$product_id.jpg"))
{
$size = GetImageSize('images/'.$product_id.'.jpg');
if($size[0]>0 && $size[1]>0)
{
echo '<img src="images/'.$product_id.'.jpg" border=0 ';
echo 'width = '. $size[0]/3 .' height = ' .$size[1]/3 . ' />';
}
}
else
echo ' ';
echo '</td>';
}
echo '<td align = "left">';
echo '<a href = "show_book.php?product_id='.$product_id.'">'.$product['product_name'].'</a> by '.$product['place_of_made'];
echo '</td><td align = "center">$'.number_format($product['price'], 2);
echo '</td><td align = "center">';
// if we allow changes, quantities are in text boxes
if ($change == true)
echo "<input type = 'text' name = "$product_id" value = "$qty" size = 3>";
else
echo $qty;
echo '</td><td align = "center">$'.number_format($product['price']*$qty,2)."</td></tr>n";
}
// display total row
echo "<tr>
<th colspan = ". (2+$images) ." bgcolor="#cccccc"> </td>
<th align = "center" bgcolor="#cccccc">
".$_SESSION['items']."
</th>
<th align = "center" bgcolor="#cccccc">
$".number_format($_SESSION['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>';
}
function display_login_form()
{
// dispaly form asking for name and password
?>
<form method='post' action="admin.php">
<table bgcolor='#cccccc'>
<tr>
<td>Username:</td>
<td><input type='text' name='username'></td></tr>
<tr>
<td>Password:</td>
<td><input type='password' name='passwd'></td></tr>
<tr>
<td colspan=2 align='center'>
<input type='submit' value="Log in"></td></tr>
<tr>
</table></form>
<?php
}
function display_admin_menu()
{
?>
<br />
<a href="index.php">Go to main site</a><br />
<a href="insert_category_form.php">Add a new category</a><br />
<a href="insert_book_form.php">Add a new book</a><br />
<a href="change_password_form.php">Change admin password</a><br />
<?php
}
function display_button($target, $image, $alt)
{
echo "<center><a href="$target"><img src="images/$image".".gif"
alt="$alt" border=0 height = 50 width = 135></a></center>";
}
function display_form_button($image, $alt)
{
echo "<center><input type = image src="images/$image".".gif"
alt="$alt" border=0 height = 50 width = 135></center>";
}
?>[/code]
[code=php]<?php
// This file contains functions used by the admin interface
// for the Book-O-Rama shopping cart.
function display_category_form($categories = '')
// This displays the category form.
// This form can be used for inserting or editing categories.
// To insert, dont pass any parameters. This will set $edit
// to false, and the form will go to insert_category.php.
// To update, pass an array containing a category. The
// form will contain the old data and point to update_category.php.
// It will also add a "Delete category" button.
{
// if passed an existing category, proceed in "edit mode"
$edit = is_array($categories);
// most of the form is in plain HTML with some
// optional PHP bits throughout
?>
<form method='post'
action="<?php echo $edit?'edit_category.php':'insert_category.php'; ?>">
<table border=0>
<tr>
<td>Category Name:</td>
<td><input type='text' name='cat_name' size=40 maxlength=40
value="<?php echo $edit?$categories['cat_name']:''; ?>"></td>
</tr>
<tr>
<td <?php if (!$edit) echo 'colspan=2'; ?> align=center>
<?php if ($edit)
echo '<input type="hidden" name="cat_id"
value="'.$categories['cat_id'].'">';
?>
<input type='submit'
value="<?php echo $edit?'Update':'Add'; ?> categories"></form>
</td>
<?php if ($edit)
// allow deletion of existing categories
{
echo '<td>';
echo '<form method="post" action="delete_category.php">';
echo '<input type="hidden" name="cat_id" value="'.$categories['cat_id'].'">';
echo '<input type="submit" value="Delete category">';
echo '</form></td>';
}
?>
</tr>
</table>
<?php
}
function display_book_form($product = '')
// This displays the book form.
// It is very similar to the category form.
// This form can be used for inserting or editing books.
// To insert, dont pass any parameters. This will set $edit
// to false, and the form will go to insert_book.php.
// To update, pass an array containing a book. The
// form will be displayed with the old data and point to update_book.php.
// It will also add a "Delete book" button.
{
// if passed an existing book, proceed in "edit mode"
$edit = is_array($product);
// most of the form is in plain HTML with some
// optional PHP bits throughout
?>
<form method='post'
action="<?php echo $edit?'edit_book.php':'insert_book.php';?>">
<table border=0>
<tr>
<td>Product_id:</td>
<td><input type='text' name='product_id'
value="<?php echo $edit?$product['product_id']:''; ?>"></td>
</tr>
<tr>
<td>Product_name:</td>
<td><input type='text' name='product_name'
value="<?php echo $edit?$product['product_name']:''; ?>"></td>
</tr>
<tr>
<td>Type of the product:</td>
<td><input type='text' name='type'
value="<?php echo $edit?$product['type']:''; ?>"></td>
</tr>
<tr>
<td>Place to made:</td>
<td><input type='text' name='place_of_made'
value="<?php echo $edit?$product['place_of_made']:''; ?>"></td>
</tr>
<tr>
<td>Material:</td>
<td><input type='text' name='material'
value="<?php echo $edit?$product['material']:''; ?>"></td>
</tr>
<tr>
<td>Category:</td>
<td><select name='cat_id'>
<?php
// list of possible categories comes from database
$cat_array=get_categories();
foreach ($cat_array as $thiscat)
{
echo '<option value=" ';
echo $thiscat['cat_id'];
echo '"';
// if existing book, put in current catgory
if ($edit && $thiscat['cat_id'] == $product['cat_id'])
echo ' selected';
echo '>';
echo $thiscat['cat_name'];
echo "n";
}
?>
</select>
</td>
</tr>
<tr>
<td>Product Price:</td>
<td><input type='text' name='price'
value="<?php echo $edit?$product['price']:''; ?>"></td>
</tr>
<tr>
<td>Description:</td>
<td><textarea rows=3 cols=50
name='description'>
<?php echo $edit?$product['description']:''; ?>
</textarea></td>
</tr>
<tr>
<td <?php if (!$edit) echo 'colspan=2'; ?> align='center'>
<?php
if ($edit)
// we need the old isbn to find book in database
// if the isbn is being updated
echo '<input type="hidden" name="oldproduct_id"
value="'.$product['product_id'].'">';
?>
<input type='submit'
value="<?php echo $edit?'Update':'Add'; ?> Product">
</form></td>
<?php
if ($edit)
{
echo '<td>';
echo '<form method="post" action="delete_book.php">';
echo '<input type="hidden" name="product_id"
value="'.$product['product_id'].'">';
echo '<input type="submit"
value="Delete book">';
echo '</form></td>';
}
?>
</td>
</tr>
</table>
</form>
<?php
}
function display_password_form()
{
// displays html change password form
?>
<br />
<form action="change_password.php" method="post">
<table width=250 cellpadding=2 cellspacing=0 bgcolor="#cccccc">
<tr><td>Old password:</td>
<td><input type="password" name="old_passwd" size=16 maxlength=16></td>
</tr>
<tr><td>New password:</td>
<td><input type="password" name="new_passwd" size=16 maxlength=16></td>
</tr>
<tr><td>Repeat new password:</td>
<td><input type="password" name="new_passwd2" size=16 maxlength=16></td>
</tr>
<tr><td colspan=2 align="center"><input type="submit" value="Change password">
</td></tr>
</table>
<br />
<?php
};
function insert_categories($cat_name)
// inserts a new category into the database
{
$conn = db_connect();
// check category does not already exist
$query = "select *
from categories
where cat_name='$cat_name'";
$result = $conn->query($query);
if (!$result || $result->num_rows!=0)
return false;
// insert new category
$query = " insert into categories values
('', '$cat_name')";
$result = $conn->query($query);
if (!$result)
return false;
else
return true;
}
function insert_book($product_id, $product_name, $type, $material, $place_of_made, $cat_id, $price, $description)
// insert a new book into the database
{
$conn = db_connect();
// check book does not already exist
$query = "select *
from product
where product_id='$product_id'";
$result = $conn->query($query);
if (!$result || $result->num_rows!=0)
return false;
// insert new book
$query = "insert into product values
('$product_id', '$product_name', '$type', '$material', '$place_of_made', '$cat_id', '$price', '$description')";
$result = $conn->query($query);
if (!$result)
return false;
else
return true;
}
function update_categories($cat_id, $cat_name)
// change the name of category with catid in the database
{
$conn = db_connect();
$query = "update categories
set cat_name='$cat_name'
where cat_id='$cat_id'";
$result = @$conn->query($query);
if (!$result)
return false;
else
return true;
}
function update_book($oldproduct_id, $product_id, $product_name, $type, $material, $place_of_made, $cat_id,
$price, $description)
// change details of book stored under $oldisbn in
// the database to new details in arguments
{
$conn = db_connect();
$query = "update product
set product_id='$product_id',
product_name ='$product_name',
material = '$material',
$place_of_made = '$place_of_made',
cat_id = '$cat_id',
type = '$type',
description = '$description'
where product_id='$oldproduct_id'";
$result = @$conn->query($query);
if (!$result)
return false;
else
return true;
}
function delete_categories($cat_id)
// Remove the category identified by catid from the db
// If there are books in the category, it will not
// be removed and the function will return false.
{
$conn = db_connect();
// check if there are any books in category
// to avoid deletion anomalies
$query = "select *
from product
where cat_id='$cat_id'";
$result = @$conn->query($query);
if (!$result || @$result->num_rows>0)
return false;
$query = "delete from categories
where cat_id='$cat_id'";
$result = @$conn->query($query);
if (!$result)
return false;
else
return true;
}
function delete_book($product_id)
// Deletes the book identified by $isbn from the database.
{
$conn = db_connect();
$query = "delete from product
where product_id='$product_id'";
$result = @$conn->query($query);
if (!$result)
return false;
else
return true;
}
?>
[/code]
>.< cant anyone tell me the wrongs??
0.1.9 — BETA 5.18