Hyperlink to another page is not working - php

When I click on Add to cart hyperlink, cart.php page is not responding (it's not echoing the add variable. Hyperlink looks fine. However, there is something wrong in cart.php. Any response is appreciated. Thanks in advance.
<html>
<head>
</head>
<body>
<table>
<tr>
<td><?php echo $row['ISBN']; ?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['title']; ?></td>
<td><?php echo $row['year']; ?></td>
<td><?php echo $row['price']; ?></td>
<td><?php echo $row['publisher']; ?></td>
<td> Add to cart</td>
<td><?php echo $row['ISBN']; ?></td>
</tr>
</table>
</body>
</html>
cart.php page:
<?php
//
session_start();
$page = 'search.php';
$lpage = 'cart.php';
$db = new mysqli('localhost', 'root', '', 'cheapbook') or die('Error connecting to MySQL server.');
mysqli_set_charset($db, 'utf8');
if (isset($_GET['add'])) {
echo $_GET['add'];
$pieces = explode(":", $_GET['add']);
$quantity = mysqli_query('SELECT ISBN, title from book WHERE ISBN=$pieces[0]');
$result = mysqli_query($db, $quantity);
while ($quantity_row = mysqli_fetch_array($result)) {
if ($quantity_row['quantity'] != $_SESSION['cart_' . $_GET['add']]) {
$_SESSION['cart_' . $_GET['add']] += 1;
}
}
if ($pieces[1] == 'SearchByBookTitle') {
header('location:' . $page . 'SearchByBookTitle=' . $pieces[2]);
}
if ($pieces[1] == 'SearchByAuthor') {
header('location:' . $page . 'SearchByAuthor=' . $pieces[2]);
echo $pieces[1];
} else {
header('location:' . $lpage);
}
}
if (isset($_GET['remove'])) {
$_SESSION['cart_' . $_GET['remove']]--;
header('location:' . $page);
}
if (isset($_GET['delete'])) {
$_SESSION['cart_' . $_GET['remove']]--;
header('location:' . $page);
}
if (isset($_GET['cart'])) {
cart();
}
function cart()
{
foreach ($_SESSION as $name => $value) {
if ($value > 0) {
if (substr($name, 0, 5) == 'curt_') {
$total = 0;
$id = substr($name, 5, (strlen($name) - 5));
$get = mysql_query("SELECT ISBN, title, price FROM book where id='.$id.'");
$result = mysqli_query($db, $get);
while ($get_row = mysqli_fetch_array($result)) {
$sub = $get_row['price'] * $value;
echo $get_row['title'] . 'X' . $value . '#Dollar' . $get_row['price'] . '=' . $sub . '[-][+][Delete]';
}
$total += $sub;
}
}
if ($total == 0) {
echo "Your cart is empty";
} else {
echo "Paypal button";
}
}
}
?>

This query coded like this of course will not work as expected
$quantity = mysqli_query('SELECT ISBN, title
from book
WHERE ISBN=$pieces[0]');
You need a double quoted string to use variable expansion, it does not work in a single quoted string.
You also need to add single quotes around the text varibale parameter value
$quantity = mysqli_query("SELECT ISBN, title
from book
WHERE ISBN='$pieces[0]'");
In future you would be well advised to add some error checking code after you attempt to execute a query and also use prepared and parameterised queries to avoid SQL Injection
$sql = "SELECT ISBN, title from book WHERE ISBN=?";
$stmt = mysqli_prepare($sql);
if ( ! $stmt ) {
echo mysqli_error();
exit;
}
$stmt->bind_param('s', $pieces[0] );
$stmt->execute();

Related

PDO issue in pagination

This is pagination code which is converted in PDO form and this is not giving any output which is connected to table , here is code of pdo pagination code
<?php
$total_num_page=2;
if (isset($_GET['page']))
{
$page_id = $_GET['page'];
}
else
{
$page_id = 1;
}
$search = '' ;
if( isset($_POST['search']) )
{
$search = urldecode($_POST['search']);
}
else if( isset($_GET['search']) )
{
$search = urldecode($_GET['search']);
}
if ($search)
{
$all_stmt=$db->prepare("select * from files where recieved_by like :needle or processed_by like :needle or purpose like :needle or file_name like :needle order by date desc");
$needle = '%' . $search . '%';
$all_stmt->bindValue(':needle', $needle, PDO::PARAM_STR);
$all_stmt->execute();
$all_post=$all_stmt->rowCount();
$total_page = ceil($all_post / $total_num_page);
$page_start_from = ($page_id - 1) * $total_num_page;
}
else
{
$all_post_query = "select * from files order by date desc";
$all_stmt=$db->prepare($all_post_query);
$all_stmt->execute();
$all_post=$all_stmt->rowCount();
$total_page = ceil($all_post / $total_num_page);
$page_start_from = ($page_id - 1) * $total_num_page;
}
?>
and here is part where i am fetching data from table database , and i don't know what is problem coming ,
<?php
if ($search)
{
$stmt=$con->prepare("select * from files where recieved_by like :needle or processed_by like :needle or purpose like :needle or file_name like :needle order by date desc limit $page_start_from, $total_num_page"); $needle = '%$search%';
$stmt->bindValue(':needle', $needle, PDO::PARAM_STR);
}
else
{
$stmt=$con->prepare("select * from files order by date desc limit $page_start_from, $total_num_page");
}
$stmt->execute();
$stmt->fetchAll();
if(count($stmt)>0){
while($row=$stmt->fetch())
{
$c_id=$row['id'];
$file=$row['file_name'];
$purpose=$row['purpose'];
$recieve=$row['recieved_by'];
$processed=$row['processed_by'];
$address=$row['address'];
$contact=$row['contact_no'];
$date=$row['date'];
?>
<tr>
<td><?php echo $c_id;?></td>
<td><?php echo $file;?></td>
<td><?php echo $purpose;?></td>
<td><?php echo $recieve;?></td>
<td><?php echo $processed;?></td>
<td><?php echo $address;?></td>
<td><?php echo $contact;?></td>
<td><?php echo $date;?></td>
</tr>
<?php
}
}
else
{
echo "No Related File Found Here ";
}
?>
</tbody>
</table>
<nav id="pagination">
<ul class="pagination">
<?php
$search_str = '';
if ($search) {
$search_str = "&search=" . urlencode($search);
}
for ($i = 1; $i <= $total_page; $i++)
echo "<li class='" . ($page_id == $i ? 'active' : '') . "'><a href='index.php?page=" . $i . $search_str . "'>$i</a></li>";
?>
and this is code of my database
<?php
$servername = "localhost";
$username = "root";
$password = "";
$con = new PDO("mysql:host=$servername;dbname=fileprogramsysteeem", $username, $password);
?>
and i also wanted to check ,if condition in page when there is no related page found in database it should show else output , Now what is i am doing wrong can anybody help me please
No Related File Found Here

Export MYSQL Result to CSV

I've been building a database to calculate termination fees.
The below code (termination.php) takes multiple rows selected from check boxes on a previous page, processes the query, and outputs in a loop to a simple HTML table. This is working as required.
<?php
require_once '.\Includes\dbcon.php';
$rowCount = count($_POST["select"]);
for ($i = 0; $i < $rowCount; $i++)
{
$sql = "UPDATE `{$_POST['customer']}` SET `DateOfCancellation`='{$_POST['dateofcancellation']} WHERE ServiceID={$_POST['select'][$i]}'";
if ($con->query($sql) === TRUE)
{
echo "";
}
else
{
echo "Error: " . $sql . "<br />" . $con->error;
}
}
?>
Back to Index</p>
<strong>Termination for <?php echo ucwords($_POST['customer']) ?> Based on Cancellation Date <?php echo $_POST['dateofcancellation'] ?></strong></p>
<table>
<tr>
<th>Service Name</th>
<th>License Start Date</th>
<th>License End Date</th>
<th>Cost Per Calendar Month</th>
<th>Balance on Termination</th>
<?php
$rowCount = count($_POST["select"]);
for ($i = 0; $i < $rowCount; $i++)
{
$sql = mysqli_query($con, "$select FROM `{$_POST['customer']}` WHERE ServiceID={$_POST['select'][$i]}");
$row[$i] = mysqli_fetch_array($sql); ?>
<tr>
<td><?php
echo $row[$i]['ServiceName']; ?></td>
<td><?php
echo $row[$i]['LicenseStart']; ?></td>
<td><?php
echo $row[$i]['LicenseEND']; ?></td>
<td>£<?php
echo $row[$i]['CostPCM']; ?></td>
<td>£<?php
echo $row[$i]['CostOfTermination']; ?></td>
<?php
}
$sql = "UPDATE `{$_POST['customer']}` SET `DateOfCancellation`='0000-00-00'";
if ($con->query($sql) === TRUE)
{
echo "";
}
else
{
echo "Error: " . $sql . "<br />" . $con->error;
}
$sum = 0;
for ($i = 0; $i < $rowCount; $i++)
{
$sum = $sum + $row[$i]['CostOfTermination'];
}
echo "<strong>The Total Balance of Termination is: </strong>£" . $sum;
echo "<p>";
$sum = 0;
for ($i = 0; $i < $rowCount; $i++)
{
$sum = $sum + $row[$i]['CostPCM'];
}
echo "<strong>Balance of Termination per Month: </strong>£" . $sum;
echo "<p>";
?>
</tr>
What do I need to do to export the data in the table to an Excel file (ideally) or a CSV file. I've tried a few different methods and can get the headers but not the actual data. I think the for loop is what's throwing me off.
Try something like this:
<?php
$titles = "Service Name,License Start Date,License End Date,Cost Per Calendar Month,Balance on Termination";
$rowCount = count($_POST["select"]);
echo $titles;
for ($i = 0; $i < $rowCount; $i++)
{
$sql = mysqli_query($con, "$select FROM `{$_POST['customer']}` WHERE ServiceID={$_POST['select'][$i]}");
$row[$i] = mysqli_fetch_array($sql);
echo
$row[$i]['ServiceName'] . "," .
$row[$i]['LicenseStart'] . "," .
$row[$i]['LicenseEND'] . "," .
$row[$i]['CostPCM'] . "," .
$row[$i]['CostOfTermination'] ."<br>";
}

Undefined variable: session start (Shopping cart attempt)

Iam no expert and just a student and I am attempting to creating a shopping cart, so far i understand that i have to use sessions to store id. my way to connect to my database is always like this:
<html>
<head>Shopping cart</head>
<?php
$session_start();
?>
<body>
<?php
$serverName = "ephesus.cs.cf.ac.uk";
$dbName = "c1429814";
$user = "c1429814";
$pass = "fakepassword";
$con = mysqli_connect($serverName, $user, $pass, $dbName);
if(!$con){
die("failure to connect to the server ".mysqli_connect_error());
}
echo "<h1> Shopping cart </h1><br/>";
echo "<div class='text_border'>";
if(isset($_GET['id']))
$id=$_GET['id'];
else
$id=1;
if(isset($_GET['action']))
$action=$_GET['action'];
else
$action="empty";
switch($action)
{
case "add":
if (isset($_SESSION['cart'][$id]))
$_SESSION['cart'][$id]++;
else
$_SESSION['cart'][$id]=1;
break;
case "remove":
if (isset($_SESSION['cart'][$id]))
{
$_SESSION['cart'][$id]--;
if($_SESSION['cart'][$id]==0)
unset($_SESSION['cast'][$id]);
}
break;
case "empty":
unset($_SESSION['cart']);
break;
/*Display cart */
if (isset($_SESSION['cart']))
{
echo "<table border = 0 cellspacing=0 width='500'>";
$total = 0;
foreach($_SESSION['cart'] as $id => $x)
{
$query = "SELECT * FROM Software WHERE id = '$product' ";
$result = mysqli_query($con, $query);
$row = mysqli_fetch_array($result);
$name = $row['name'];
$name=substr($name, 0, 40);
$price = $row['price'];
$the_cost= $price * $x;
$total = $total+$the_cost;
echo "<tr>";
echo "<td align='left'>$name </td>";
echo "<td align='right'>$x action=remove'>reduce'</td>";
echo "<td align='right'>= $the_cost";
echo "</tr>";
}
echo "<tr>";
echo "<td align='right'><br>Total=</td>";
echo "<td align='right'><b><br> $total </b></td>";
echo "</tr>";
echo "</table>";
}
else
echo "Cart is empty";
}
?>
</body>
</html>
I am getting an error which is called Undefined variable session, im not really sure what kind of variable i need to define to get around this? or is the way i connect to the database? any information that would could give me sufficient help and tips would be greatly appreciated. :)
$ is used for php variables...
you do not need $ when you use functions,
and open it above all code...
so here :
//...
session_start();
//...
will be better....
use session_start(); (without the dollar sign) instead, since you are calling a function not accessing a variable. And as a side note: "To use cookie-based sessions, session_start() must be called before outputing anything to the browser." More here: http://php.net/manual/en/function.session-start.php
Try to open the session before the HTML and remove $
Like this:
<?php
session_start();
?>
<html>
<head>Shopping cart</head>
<body>
<?php
$serverName = "ephesus.cs.cf.ac.uk";
$dbName = "c1429814";
$user = "c1429814";
$pass = "ugsok4";
$con = mysqli_connect($serverName, $user, $pass, $dbName);
if(!$con){
die("failure to connect to the server ".mysqli_connect_error());
}
echo "<h1> Shopping cart </h1><br/>";
echo "<div class='text_border'>";
if(isset($_GET['id']))
$id=$_GET['id'];
else
$id=1;
if(isset($_GET['action']))
$action=$_GET['action'];
else
$action="empty";
switch($action)
{
case "add":
if (isset($_SESSION['cart'][$id]))
$_SESSION['cart'][$id]++;
else
$_SESSION['cart'][$id]=1;
break;
case "remove":
if (isset($_SESSION['cart'][$id]))
{
$_SESSION['cart'][$id]--;
if($_SESSION['cart'][$id]==0)
unset($_SESSION['cast'][$id]);
}
break;
case "empty":
unset($_SESSION['cart']);
break;
/*Display cart */
if (isset($_SESSION['cart']))
{
echo "<table border = 0 cellspacing=0 width='500'>";
$total = 0;
foreach($_SESSION['cart'] as $id => $x)
{
$query = "SELECT * FROM Software WHERE id = '$product' ";
$result = mysqli_query($con, $query);
$row = mysqli_fetch_array($result);
$name = $row['name'];
$name=substr($name, 0, 40);
$price = $row['price'];
$the_cost= $price * $x;
$total = $total+$the_cost;
echo "<tr>";
echo "<td align='left'>$name </td>";
echo "<td align='right'>$x action=remove'>reduce'</td>";
echo "<td align='right'>= $the_cost";
echo "</tr>";
}
echo "<tr>";
echo "<td align='right'><br>Total=</td>";
echo "<td align='right'><b><br> $total </b></td>";
echo "</tr>";
echo "</table>";
}
else
echo "Cart is empty";
}
?>
</body>
</html>
Please use the following code which is simplified your code. '$' should not use in your session_start();
<?php
session_start();
?>
<head>Shopping cart</head>
<body>
<?php
$serverName = "ephesus.cs.cf.ac.uk";
$dbName = "c1429814";
$user = "c1429814";
$pass = "ugsok4";
$con = mysqli_connect($serverName, $user, $pass, $dbName);
if (!$con) {
die("failure to connect to the server " . mysqli_connect_error());
}
echo "<h1> Shopping cart </h1><br/>";
echo "<div class='text_border'>";
$id = isset($_GET['id']) ? $_GET['id'] : 1;
$action = isset($_GET['action']) ? $_GET['action'] : 'empty';
switch ($action) {
case "add":
if (isset($_SESSION['cart'][$id])) {
$_SESSION['cart'][$id] ++;
} else {
$_SESSION['cart'][$id] = 1;
}
break;
case "remove":
if (isset($_SESSION['cart'][$id])) {
$_SESSION['cart'][$id] --;
if ($_SESSION['cart'][$id] == 0)
unset($_SESSION['cast'][$id]);
}
break;
case "empty":
unset($_SESSION['cart']);
break;
/* Display cart */
if (isset($_SESSION['cart'])) {
echo "<table border = 0 cellspacing=0 width='500'>";
$total = 0;
foreach ($_SESSION['cart'] as $id => $x) {
$query = "SELECT * FROM Software WHERE id = '$product' ";
$result = mysqli_query($con, $query);
$row = mysqli_fetch_array($result);
$name = $row['name'];
$name = substr($name, 0, 40);
$price = $row['price'];
$the_cost = $price * $x;
$total = $total + $the_cost;
echo "<tr>";
echo "<td align='left'>$name </td>";
echo "<td align='right'>$x action=remove'>reduce'</td>";
echo "<td align='right'>= $the_cost";
echo "</tr>";
}
echo "<tr>";
echo "<td align='right'><br>Total=</td>";
echo "<td align='right'><b><br> $total </b></td>";
echo "</tr>";
echo "</table>";
} else {
echo "Cart is empty";
}
}
?>
</body>

How to add multiple checkboxes data to MySQL database using PHP PDO?

try {
$qry = $conn->prepare("SELECT * FROM school_periods WHERE account_id = :a_id");
$qry->execute(array(':a_id'=>$_SESSION['user_account']));
$qry->setFetchMode(PDO::FETCH_OBJ);
while($row = $qry->fetch()) {
?>
<tr>
<td width='35%'><input type='checkbox' name='periods' value=''></td>
<td width='35%'><?=$row->period_name; ?></td>
<td width='35%'><?=$row->start; ?> </td>
<td><?=$row->end; ?></td>
</tr>
<?php
}
} catch(PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
}
If the user checks the number of the checkbox, I want to add the checkbox name and value in the database. I tried to achieve this as follows:
<?php
$schoolyear = $_REQUEST['schoolyear'];
$start = $_REQUEST['start'];
$end = $_REQUEST['end'];
$start = date2mysql($start);
$end = date2mysql($end);
$holiday = $_POST['holiday'];
$status = 1;
$test = 0;
if ($test == 1) {
echo $schoolyear;
echo '<br />';
echo $start;
echo '<br />';
echo $end;
echo '<br />';
echo $status;
echo '<br />';
echo $_SESSION['user_account'];
}
try {
$sqladdyr = "INSERT INTO school_years (account_id,year_name,start,end,status,added,updated) VALUES (:a_id,:name,:start,:end,:status,NOW(),NOW())";
$q = $conn->prepare($sqladdyr);
$q->bindParam(":start", $start, PDO::PARAM_STR);
$q->bindParam(":end", $end, PDO::PARAM_STR);
$q->bindParam(":a_id", $_SESSION['user_account'], PDO::PARAM_STR);
$q->bindParam(":name", $schoolyear, PDO::PARAM_STR);
$q->bindParam(":status", $status, PDO::PARAM_STR);
$q->execute();
$id = $conn->prepare("SELECT MAX('year_id') FROM school_years");
//Set needed id.
$id->execute();
$id->setFetchMode(PDO::FETCH_OBJ);
while ($idval = $id->fetch()) {
$id_val = $idval->year_id;
}
foreach ( $holiday as $key => $value ):
$stmt = $conn->prepare("INSERT INTO holidays(account_id,year_id,holiday_name,start) VALUES(:a_id,:yid,:name,:date)");
$stmt->execute(array(
':a_id' => $_SESSION['user_account'],
'year_id'=>$id_val,
':name'=>$_POST['holiday'][$key],
':date'=>$_POST['holiday'][$value] // assuming this is the same for all rows?
));
endforeach;
} catch(PDOException $e) {
echo 'Error: ' . $e->getMessage();
}
Unfortunately, this does not seem to work. How can I solve this issue?

Shopping cart/basket session not going to database: PHP MySQL

I am writing a program with php/mysql in which logged in users use a points system to order items through a shopping cart (no money,paypal,credit card payments,shipping taxes etc. are involved - points only). My php knowledge is basic to low intermediate.
I have two scripts below:
The shopping cart/basket called view_cart.php
This works fine (and disables checkout if they don't have enough points).
Order submission to database called submit_order.php
I am having trouble with linking the shopping cart session to the submit order page/database. I get the first error message but it creates a new order under the orders table but only with the logged in users ID number, while the total comes to 0. Nothing happens with the order_contents table either.
I am guessing it is something to do with the 'cart' session variables/array so if someone could help or steer me in the right direction that would be great.
Thanks A
view_cart.php below:
<?php //view_cart.php
$page_title = 'ViewCart';
include ('./includes/header.html');
if (!isset($_SESSION['users_id'])) {
$url = 'http://' . $_SERVER['HTTP_HOST']
. dirname($_SERVER['PHP_SELF']);
if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) {
$url = substr ($url, 0, -1);
}
$url .= '/login.php';
ob_end_clean();
header("Location: $url");
exit();
}
$rwp = $_SESSION['points'];
$problem = FALSE;
if (isset($_POST['submitted']))
{
foreach ($_POST['qty'] as $k => $v) {
$pid = (int) $k;
$qty = (int) $v;
if ( $qty == 0 ) {
unset ($_SESSION['cart'][$pid]);
} elseif ( $qty > 0 ) {
$_SESSION['cart'][$pid] ['quantity'] = $qty;
}
}
}
$empty = TRUE;
if (isset ($_SESSION['cart'])) {
foreach ($_SESSION['cart'] as $key =>$value) {
if (isset($value)) {
$empty = FALSE;
break;
}
}
}
if (!$empty) {
require_once ('mysql_connect.php');
$query = "SELECT users_id, points FROM user_points
WHERE user_points.users_id = users.users_id";
$result = mysql_query($query);
$query = "SELECT products_id, products_name FROM categories, products
WHERE categories.categories_id = products.categories_id AND products.products_id
IN (";foreach ($_SESSION['cart'] as $pid =>$value) {
$query .= $pid . ',';
}
$query = substr ($query, 0, -1) . ') ORDER BY categories.categories_name ASC';
$result = mysql_query($query);
echo '
<table border="0" width="100%" cellspacing="1" cellpadding="5"
align="center">
<tr class="top">
<td align="left" width="46%"><b>Product</b></td>
<td align="right" width="18%"><b>Price</b></td>
<td align="center" width="16%"><b>Qty</b></td>
<td align="right" width="20%"><b>Sub Total</b></td>
</tr>
<form action="view_cart.php" method="post">
';
$total = 0;
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$subtotal = $_SESSION['cart'][$row
['products_id']]['quantity'] *
$_SESSION['cart'][$row ['products_id']]['price'];
$total += $subtotal;
echo " <tr>
<td align=\"left\">{$row['products_name']}</td>
<td align=\"right\">{$_SESSION['cart'][$row['products_id']] ['price']} pts</td>
<td align=\"center\"><input type=\"text\" size=\"3\"
name=\"qty[{$row['products_id']}]\"
value=\"{$_SESSION['cart'][$row['products_id']]['quantity']}\" /></td>
<td align=\"right\">" . number_format ($subtotal) . " pts</td>
</tr>\n";
}
mysql_close($dbc);
$str = '<tr class="even">
<td colspan="3" align="right"><b> TOTAL:<b></td>
<td align="right"><b>' . number_format ($total) . ' pts </b></td>
</tr>
</table>
<br />
<div align="center"><input type="submit" name="submit" value="Update" />
<input type="hidden" name="submitted" value="TRUE" />
</form><br /><br /></div>';
if($up >= $total) {
$str .='Submit Order</p>';
}
else {
$str .='<p>You do not have enough points to proceed to checkout</p>';
}
echo $str;
} else {
echo '<p>Your cart is currently empty.</p>';
}
?>
<?php
include ('./includes/footer.html');
?>
Here is the submit_order.php script.
<?php
$page_title = 'Order Confirmation';
include ('./includes/header.html');
if (!isset($_SESSION['users_id'])) {
$url = 'http://' . $_SERVER['HTTP_HOST']
. dirname($_SERVER['PHP_SELF']);
if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) {
$url = substr ($url, 0, -1);
}
$url .= '/login.php';
ob_end_clean();
header("Location: $url");
exit();
}
$users = $_SESSION['users_id']; // Temporary.
$total = 0;
require_once ('mysql_connect.php'); // Connect to the database.
#mysqli_autocommit ($dbc, FALSE);
$query = "INSERT INTO orders (users_id, total) VALUES
($users, $total)";
$result = #mysql_query($query);
if (#mysql_affected_rows($dbc) == 1) {
$oid = #mysql_insert_id();
$query = "INSERT INTO order_contents (order_id, products_id, quantity, price)
VALUES ";
foreach ($_SESSION['cart'] as $pid => $value) {
$query .= "($oid, $pid, {$value['quantity']}, {$value['price']})";
}
$query = substr($query, 0, -2);
$result = #mysql_query($query);
if (#mysql_affected_rows($dbc) == count($_SESSION['cart'])) {
#mysqli_commit($dbc);
#mysql_close($dbc);
unset($_SESSION['cart']);
echo '<p>Thank you for your order.
It has been submitted for processing.</p>';
} else {
#mysqli_rollback($dbc);
#mysql_close($dbc);
echo '<p>Your order could not be processed due to a system error.
You will be contacted in order to have the problem fixed.
We apologize for the inconvenience 1.</p>';
}
}
else {
#mysqli_rollback($dbc);
#mysql_close($dbc);
echo '<p>Your order could not be processed due to a system error.
You will be contacted in order to have the problem fixed.
We apologize for the inconvenience 2.</p>';
}
?>
</div></div>
<?php
include ('./includes/footer.html');
?>
I can't see
session_start();
Anywhere in here, are you calling it from a parent including file?
I guess you put session_start() in the wrong place. It must be called before the <html> tag.

Categories