The script was working, I added to it and now cant find why it wont work anymore. Would really appreciate if anyone can spot it. I turned on errors in PHP but it didnt bring anything up...
<?
/* Sales Sheet Process File */
include("../include/configuration.php");
include("../include/session.php");
$pusername=$session->username;
$dateadded=date("Y-m-d H:i:s");
$thedateday=$_POST['day'];
if (strlen($thedateday) < 2) {
$thedateday = '0' .$thedateday;
}
$thedatemonth=$_POST['month'];
if (strlen($thedatemonth) < 2) {
$thedatemonth = '0' .$thedatemonth;
}
$thedateyear=$_POST['year'];
if (strlen($thedateyear) < 2) {
$thedateyear = '20' .$thedateyear;
}
$pdate=$thedateyear.$thedatemonth.$thedateday;
/* Date for order one date */
$othedateday_one=$_POST['oday_one'];
if (strlen($othedateday_one) < 2) {
$othedateday_one = '0' .$othedateday_one;
}
$othedatemonth-one=$_POST['omonth_one'];
if (strlen($othedatemonth) < 2) {
$othedatemonth_one = '0' .$othedatemonth_one;
}
$othedateyear_one=$_POST['oyear_one'];
if (strlen($othedateyear_one) < 2) {
$othedateyear_one = '20' .$othedateyear_one;
}
$podate_one=$othedateyear_one.$othedatemonth_one.$othedateday_one;
/* Date for order two date */
$othedateday_two=$_POST['oday_two'];
if (strlen($othedateday_two) < 2) {
$othedateday_two = '0' .$othedateday_two;
}
$othedatemonth-one=$_POST['omonth_two'];
if (strlen($othedatemonth) < 2) {
$othedatemonth_two = '0' .$othedatemonth_two;
}
$othedateyear_two=$_POST['oyear_two'];
if (strlen($othedateyear_two) < 2) {
$othedateyear_two = '20' .$othedateyear_two;
}
$podate_two=$othedateyear_two.$othedatemonth_two.$othedateday_two;
/* Date for order three date */
$othedateday_three=$_POST['oday_three'];
if (strlen($othedateday_three) < 2) {
$othedateday_three = '0' .$othedateday_three;
}
$othedatemonth-one=$_POST['omonth_three'];
if (strlen($othedatemonth) < 2) {
$othedatemonth_three = '0' .$othedatemonth_three;
}
$othedateyear_three=$_POST['oyear_three'];
if (strlen($othedateyear_three) < 2) {
$othedateyear_three = '20' .$othedateyear_three;
}
$podate_three=$othedateyear_three.$othedatemonth_three.$othedateday_three;
/* Date for order four date */
$othedateday_four=$_POST['oday_four'];
if (strlen($othedateday_four) < 2) {
$othedateday_four = '0' .$othedateday_four;
}
$othedatemonth-one=$_POST['omonth_four'];
if (strlen($othedatemonth) < 2) {
$othedatemonth_four = '0' .$othedatemonth_four;
}
$othedateyear_four=$_POST['oyear_four'];
if (strlen($othedateyear_four) < 2) {
$othedateyear_four = '20' .$othedateyear_four;
}
$podate_four=$othedateyear_four.$othedatemonth_four.$othedateday_four;
/* */
$plogid=$_POST['logid']; /* log_id */
$pnewusername=$_POST['new_username'];
$ptender=$_POST['tender'];
$pcustomer=$_POST['customer'];
$pmaindesc=mysql_real_escape_string($_POST['description']);
$pdesc_one=mysql_real_escape_string($_POST['description_one']);
$psupplier_one=$_POST['supplier_one'];
$psupplier_ref_one=$_POST['supplier_ref_one'];
$psupplier_cost_one=$_POST['supplier_cost_one'];
$pdelivery_cost_one=$_POST['delivery_cost_one'];
$pquoted_one=$_POST['quoted_one'];
$plpncharge_one=$_POST['lpncharge_one'];
$pordered_one=$_POST['ordered_one'];
$pdesc_two=mysql_real_escape_string($_POST['description_two']);
$psupplier_two=$_POST['supplier_two'];
$psupplier_ref_two=$_POST['supplier_ref_two'];
$psupplier_cost_two=$_POST['supplier_cost_two'];
$pdelivery_cost_two=$_POST['delivery_cost_two'];
$pquoted_two=$_POST['quoted_two'];
$plpncharge_two=$_POST['lpncharge_two'];
$pordered_two=$_POST['ordered_two'];
$pdesc_three=mysql_real_escape_string($_POST['description_three']);
$psupplier_three=$_POST['supplier_three'];
$psupplier_ref_three=$_POST['supplier_ref_three'];
$psupplier_cost_three=$_POST['supplier_cost_three'];
$pdelivery_cost_three=$_POST['delivery_cost_three'];
$pquoted_three=$_POST['quoted_three'];
$plpncharge_three=$_POST['lpncharge_three'];
$pordered_three=$_POST['ordered_three'];
$pdesc_four=mysql_real_escape_string($_POST['description_four']);
$psupplier_four=$_POST['supplier_four'];
$psupplier_ref_four=$_POST['supplier_ref_four'];
$psupplier_cost_four=$_POST['supplier_cost_four'];
$pdelivery_cost_four=$_POST['delivery_cost_four'];
$pquoted_four=$_POST['quoted_four'];
$plpncharge_four=$_POST['lpncharge_four'];
$pordered_four=$_POST['ordered_four'];
$pdeliveredto=$_POST['deliveredto'];
$paccount=$_POST['account'];
$ppo=$_POST['po'];
$pcustomer_ref=$_POST['customer_ref'];
$pdelivered=$_POST['delivered'];
$precharged=$_POST['recharged'];
$pinvoice_received=$_POST['invoice_received'];
$pprofit=$_POST['profit'];
$pextranotes=$_POST['notes'];
switch($_POST['opt']) {
case "addsalesref":
$query = mysql_query("SELECT Tender FROM sales_ref ORDER BY Tender Desc LIMIT 0,1");
while($row = mysql_fetch_array($query))
{
if ($ptender == $row['Tender']){
$ptender = ++$row['Tender'];
}
}
mysql_query("INSERT INTO sales_ref (Tender, Date, username, customerid, Description, Delivered_To, Account, PO, Customer_Ref, Delivered, Recharged, Invoice_Received, Profit, Extra_Notes) VALUES ('$ptender', '$pdate', '$pusername', '$pcustomer', '$pdescription', '$pdeliveredto', '$paccount', '$ppo', '$podate', '$pcustomer_ref', '$pdelivered', '$precharged', '$pinvoice_received', '$pprofit', '$pextranotes') ")
or die(mysql_error());
mysql_query("INSERT INTO sales_items (Tender, Description, Supplier, Supplier_Ref, Supplier_cost, Delivery_Cost, Quoted, LPN_Charge, Ordered, Order_Date) VALUES ('$ptender', '$pdescription_one', '$psupplier_one', '$psupplier_ref_one', '$psupplier_cost_one', '$pdelivery_cost_one', '$pquoted_one', '$plpncharge_one', '$pordered_one', '$podate_one') ")
or die(mysql_error());
mysql_query("INSERT INTO sales_items (Tender, Description, Supplier, Supplier_Ref, Supplier_cost, Delivery_Cost, Quoted, LPN_Charge, Ordered, Order_Date) VALUES ('$ptender', '$pdescription_two', '$psupplier_two', '$psupplier_ref_two', '$psupplier_cost_two', '$pdelivery_cost_two', '$pquoted_two', '$plpncharge_two', '$pordered_two', '$podate_two') ")
or die(mysql_error());
mysql_query("INSERT INTO sales_items (Tender, Description, Supplier, Supplier_Ref, Supplier_cost, Delivery_Cost, Quoted, LPN_Charge, Ordered, Order_Date) VALUES ('$ptender', '$pdescription_three', '$psupplier_three', '$psupplier_ref_three', '$psupplier_cost_three', '$pdelivery_cost_three', '$pquoted_three', '$plpncharge_three', '$pordered_three', '$podate_three') ")
or die(mysql_error());
mysql_query("INSERT INTO sales_items (Tender, Description, Supplier, Supplier_Ref, Supplier_cost, Delivery_Cost, Quoted, LPN_Charge, Ordered, Order_Date) VALUES ('$ptender', '$pdescription_four', '$psupplier_four', '$psupplier_ref_four', '$psupplier_cost_four', '$pdelivery_cost_four', '$pquoted_four', '$plpncharge_four', '$pordered_four', '$podate_four') ")
or die(mysql_error());
break;
case "editsalesref":
mysql_query("UPDATE sales_ref SET username='$pnewusername', tender='$ptender', Date='$pdate', customerid='$pcustomer', description='$pdescription', Supplier='$psupplier', Supplier_Ref='$psupplier_ref', Supplier_cost='$psupplier_cost', Delivery_Cost='$pdelivery_cost', Quoted='$pquoted', LPN_Charge='$plpncharge', PO='$ppo', Order_Date='$podate', Customer_Ref='$pcustomer_ref', Delivered='$pdelivered', Recharged='$precharged', Invoice_Received='$pinvoice_received', Profit='$pprofit', Extra_Notes='$pextranotes' WHERE log_id = '$plogid' ")
or die(mysql_error());
while (list($key, $value) = each($_POST['ordered'])) {
if ($value == 'Y'){
$query = mysql_query("UPDATE sales_ref SET ordered='yes' WHERE log_id = '$key' ");
} else {
$query2 = mysql_query("UPDATE sales_ref SET ordered='no' WHERE log_id = '$key' ");
echo mysql_error($query);
}
}
while (list($key, $value) = each($_POST['delivered'])) {
if ($value == 'Y'){
$query = mysql_query("UPDATE sales_ref SET Delivered='yes' WHERE log_id = '$key' ");
} else {
$query2 = mysql_query("UPDATE sales_ref SET Delivered='no' WHERE log_id = '$key' ");
echo mysql_error($query);
}
}
while (list($key, $value) = each($_POST['invoice_received'])) {
if ($value == 'Y'){
$query = mysql_query("UPDATE sales_ref SET Invoice_Received='yes' WHERE log_id = '$key' ");
} else {
$query2 = mysql_query("UPDATE sales_ref SET Invoice_Received='no' WHERE log_id = '$key' ");
echo mysql_error($query);
}
}
while (list($key, $value) = each($_POST['account'])) {
if ($value == 'Acc'){
$query = mysql_query("UPDATE sales_ref SET Account='Acc' WHERE log_id = '$key' ");
} else {
$query2 = mysql_query("UPDATE sales_ref SET Account='CC' WHERE log_id = '$key' ");
echo mysql_error($query);
}
}
while (list($key, $value) = each($_POST['recharged'])) {
if ($value == 'Y'){
$query = mysql_query("UPDATE sales_ref SET Recharged='yes' WHERE log_id = '$key' ");
} else {
$query2 = mysql_query("UPDATE sales_ref SET Recharged='no' WHERE log_id = '$key' ");
echo mysql_error($query);
}
}
while (list($key, $value) = each($_POST['deliveredto'])) {
if ($value == 'LPN'){
$query = mysql_query("UPDATE sales_ref SET Delivered_To='LPN' WHERE log_id = '$key' ");
} else {
$query2 = mysql_query("UPDATE sales_ref SET Delivered_To='Customer' WHERE log_id = '$key' ");
echo mysql_error($query);
}
}
while (list($key, $value) = each($_POST['quoted'])) {
if ($value == 'yes'){
$query = mysql_query("UPDATE sales_ref SET Quoted='yes' WHERE log_id = '$key' ");
} else {
$query2 = mysql_query("UPDATE sales_ref SET Quoted='no' WHERE log_id = '$key' ");
echo mysql_error($query);
}
}
break;
}
header("Location: " . $_SERVER['HTTP_REFERER']); /* Redirect browser */
?>