Oh ok. Here it is
<? include("protect.php"); ?>
<? php
$a = $HTTP_POST_VARS["a"];
$i = $HTTP_POST_VARS["i"];
$j = $HTTP_POST_VARS["j"];
$k = $HTTP_POST_VARS["k"];
$l = $HTTP_POST_VARS["l"];
$e = $HTTP_POST_VARS["e"];
$f= $HTTP_POST_VARS["f"];
$ssrid = $HTTP_POST_VARS["ssrid"];
$advanceid = $HTTP_POST_VARS["advanceid"];
$iid = $HTTP_POST_VARS["iid"];
$advance = $HTTP_POST_VARS["advance"];
$user = $HTTP_POST_VARS["user"];
$total_cost = $i + $j + $k + $l ;
$payable = $total_cost - $f- $advance ;
$fbe = $k*0.15*0.1765 ;
mysql_connect("localhost", $dbname, $dbpasswd )
or die ("Unable to connect to server.");
mysql_select_db($database)
or die ("Unable to select database.");
$sqla = "INSERT INTO `Service_Costs` (SSRID,iid, user, Conveyance, Phone, Meals, Misc, Fee, Board, Ticket,Receipt, TotalCost, Payable) VALUES ($ssrid,$iid, '$user', $fbe, $j, $g, $h, $k, $i, $l, $f, $total_cost, $payable )";
$resulta = mysql_query($sqla) or die (mysql_error() );
$sqlb="select max(SICID) from `Service_Costs`";
$resultb = mysql_query($sqlb) or die (mysql_error() );
$myrowb = mysql_fetch_row($resultb);
$sicid = $myrowb[0];
$sql21 = "UPDATE `Service_Advance` SET Settled=1 WHERE advanceid=$advanceid";
$result21 = mysql_query($sql21)
or die (mysql_error());
?>
// The foll. part is both an independent script file as well as a continuation of the above as it appears in 2 separate reports.
<?php
$a = $HTTP_POST_VARS["a"];
mysql_connect("localhost", $dbname, $dbpasswd )
or die ("Unable to connect to server.");
mysql_select_db($database)
or die ("Unable to select database.");
$result = mysql_query("SELECT * FROM `Visit_Report` WHERE Visitid= $a ");
$myrow = mysql_fetch_array($result);
$customer = $myrow["Company"];
$last = $myrow["Lastname"];
list($customer0, $customer1) = explode(",", $customer);
echo $customer0;
echo $customer1;
$sql1 = "SELECT * FROM `Customers` WHERE `Company` = '$customer0' AND `Lastname` = '$last' ";
echo $sql1;
$result1 = mysql_query($sql1) or die (mysql_error());
$myrow1 = mysql_fetch_array($result1);
$street = $myrow1["Street"];
// THIS WORKS IF I DONT USE THE $last in the above query)
printf("<tr>
<br><font color=orange>Meeting with</font> : %s <br>
<font color=orange>Customer</font> : %s<br>
<font color=orange>Address</font> : %s : <br>
<font color=orange>Visit Id</font> : %s<br>
<font color=orange>Discussion</font> : %s : <br>
$myrow1["Lastname]"],
$customer0, // This works but if I replace it with $myrow1["Company"] it doesnt work.
$myrow1["Street"],
$myrow["Visitid"], // this comes from the 1st sql stmt
$myrow["Disc"] ); // this comes from the 1st sql stmt
?>