Hi people, keep getting this errorParse error: parse error, unexpected
T_STRING in order_fns.php line 91. the code is below for the file and
I've indicated line 91
<?php
function process_card($c ard_details)
{
// connect to payment gateway or
// use gpg to encrypt and mail or
// store in DB if you really want to
return true;
}
function insert_order($o rder_details)
{
global $HTTP_SESSION_V ARS;
//extract order_details out as variables
extract($order_ details);
//set shipping address same as address
if(!$ship_name& &!$ship_address &&!$ship_city&& !$ship_state&&! $ship_zip&&!$sh ip_country)
{
$ship_name = $name;
$ship_address = $address;
$ship_city = $city;
$ship_state = $state;
$ship_zip = $zip;
$ship_country = $country;
}
$conn = db_connect();
//insert customer address
$query = "select customerid from customers where
name = '$name' and address = '$address'
and city = '$city' and state = '$state'
and zip = '$zip' and country = '$country'";
$result = mysql_query($qu ery);
if(mysql_numrow s($result)>0)
{
$customer_id = mysql_result($r esult, 0, 'customerid');
}
else
{
$query = "insert into customers values
('', '$name','$addre ss','$city','$s tate','$zip','$ country')";
$result = mysql_query($qu ery);
if (!$result)
return false;
}
$query = "select customerid from customers where
name = '$name' and address = '$address'
and city = '$city' and state = '$state'
and zip = '$zip' and country = '$country'";
$result = mysql_query($qu ery);
if(mysql_numrow s($result)>0)
$customerid = mysql_result($r esult, 0, 'customerid');
else
return false;
$date = date('Y-m-d');
$query = "insert into orders values
('', $customerid, ".$HTTP_SESSION _VARS['total_price'].",
'$date', 'PARTIAL', '$ship_name',
'$ship_address' ,'$ship_city',' $ship_state','$ ship_zip',
'$ship_country' )";
$result = mysql_query($qu ery);
if (!$result)
return false;
$query = "select orderid from orders where
customerid = $customerid and
amount > ".$HTTP_SESSION _VARS['total_price']."-.001 and
amount < ".$HTTP_SESSION _VARS['total_price']."+.001 and
date = '$date' and
order_status = 'PARTIAL' and
ship_name = '$ship_name' and
ship_address = '$ship_address' and
ship_city = '$ship_city' and
ship_state = '$ship_state' and
ship_zip = '$ship_zip' and
ship_country = '$ship_country' ;
$result = mysql_query($qu ery);
if(mysql_numrow s($result)>0)
$orderid = mysql_result($r esult, 0, 'orderid');
else
return false;
// insert each book
foreach($HTTP_S ESSION_VARS['cart'] as $isbn => $quantity)
{
$detail = get_book_detail s($isbn);
/*Line 91*/$query = "delete from order_items where
orderid = '" . $orderid . "' and isbn = '" . $isbn .
"'";
$result = mysql_query($qu ery);
$query = "insert into order_items values
('$orderid', '$isbn', ".$detail['price'].", $quantity");
$result = mysql_query($qu ery);
if(!$result)
return false;
}
return $orderid;
}
?>
but I think its got to do with the line before
$detail = get_book_detail s($isbn); and here is the get_book_detail s
function
function get_book_detail s($isbn)
{
// query database for all details for a particular book
if (!$isbn || $isbn=='')
return false;
$conn = db_connect();
$query = "select * from books where isbn='$isbn'";
$result = @mysql_query($q uery);
if (!$result)
return false;
$result = @mysql_fetch_ar ray($result);
return $result;
}
T_STRING in order_fns.php line 91. the code is below for the file and
I've indicated line 91
<?php
function process_card($c ard_details)
{
// connect to payment gateway or
// use gpg to encrypt and mail or
// store in DB if you really want to
return true;
}
function insert_order($o rder_details)
{
global $HTTP_SESSION_V ARS;
//extract order_details out as variables
extract($order_ details);
//set shipping address same as address
if(!$ship_name& &!$ship_address &&!$ship_city&& !$ship_state&&! $ship_zip&&!$sh ip_country)
{
$ship_name = $name;
$ship_address = $address;
$ship_city = $city;
$ship_state = $state;
$ship_zip = $zip;
$ship_country = $country;
}
$conn = db_connect();
//insert customer address
$query = "select customerid from customers where
name = '$name' and address = '$address'
and city = '$city' and state = '$state'
and zip = '$zip' and country = '$country'";
$result = mysql_query($qu ery);
if(mysql_numrow s($result)>0)
{
$customer_id = mysql_result($r esult, 0, 'customerid');
}
else
{
$query = "insert into customers values
('', '$name','$addre ss','$city','$s tate','$zip','$ country')";
$result = mysql_query($qu ery);
if (!$result)
return false;
}
$query = "select customerid from customers where
name = '$name' and address = '$address'
and city = '$city' and state = '$state'
and zip = '$zip' and country = '$country'";
$result = mysql_query($qu ery);
if(mysql_numrow s($result)>0)
$customerid = mysql_result($r esult, 0, 'customerid');
else
return false;
$date = date('Y-m-d');
$query = "insert into orders values
('', $customerid, ".$HTTP_SESSION _VARS['total_price'].",
'$date', 'PARTIAL', '$ship_name',
'$ship_address' ,'$ship_city',' $ship_state','$ ship_zip',
'$ship_country' )";
$result = mysql_query($qu ery);
if (!$result)
return false;
$query = "select orderid from orders where
customerid = $customerid and
amount > ".$HTTP_SESSION _VARS['total_price']."-.001 and
amount < ".$HTTP_SESSION _VARS['total_price']."+.001 and
date = '$date' and
order_status = 'PARTIAL' and
ship_name = '$ship_name' and
ship_address = '$ship_address' and
ship_city = '$ship_city' and
ship_state = '$ship_state' and
ship_zip = '$ship_zip' and
ship_country = '$ship_country' ;
$result = mysql_query($qu ery);
if(mysql_numrow s($result)>0)
$orderid = mysql_result($r esult, 0, 'orderid');
else
return false;
// insert each book
foreach($HTTP_S ESSION_VARS['cart'] as $isbn => $quantity)
{
$detail = get_book_detail s($isbn);
/*Line 91*/$query = "delete from order_items where
orderid = '" . $orderid . "' and isbn = '" . $isbn .
"'";
$result = mysql_query($qu ery);
$query = "insert into order_items values
('$orderid', '$isbn', ".$detail['price'].", $quantity");
$result = mysql_query($qu ery);
if(!$result)
return false;
}
return $orderid;
}
?>
but I think its got to do with the line before
$detail = get_book_detail s($isbn); and here is the get_book_detail s
function
function get_book_detail s($isbn)
{
// query database for all details for a particular book
if (!$isbn || $isbn=='')
return false;
$conn = db_connect();
$query = "select * from books where isbn='$isbn'";
$result = @mysql_query($q uery);
if (!$result)
return false;
$result = @mysql_fetch_ar ray($result);
return $result;
}
Comment