Right, i have a stock control system where the user enters all details about a sale and the system calls 4 methods to save the sale, save the items within the sale, and also change the inventory accordingly.
when a sale is successfully entered, the function should return with "true" or "false" so i can give the output accordingly.
Here is the function and the code that calls it:
function:
Code: Select all
function insertNewSale($salesArray){
$insertToSales = "INSERT IGNORE INTO sales (Date, Time, BuyerID, PostPacking, Payment_Method, PaypalFee, Add_Info) VALUES ('".$salesArray['todaysDate']."','".$salesArray['saleTime']."','".$salesArray['buyerID']."','".$salesArray['postPack']."','".$salesArray['payMeth']."','".$salesArray['paypal']."','".$salesArray['addInfo']."')";
if(mysql_query($insertToSales)){
return true;
}else{
return false;
}
}
Code: Select all
if($_SESSION['pageLoad'] == 1){
$newSale = insertNewSale($_SESSION);
if($newSale){
$saleN = getSalesNum($_SESSION);
$insertSaleItem = insertSaleItem($_SESSION, $saleN);
changeInv($_SESSION);
echo "<div id='checkSale'>";
echo "<table border=0>";
echo "<tr><td align = left>Date: </td><td align = right>".$date."</td></tr>";
echo "<tr><td align = left>Time: </td><td align = right>".$time."</td></tr>";
echo "<tr><td align = left>Buyer ID: </td><td align = right>".$buyerID."</td></tr>";
echo "<tr><td colspan=2 align=center>--------------------------------</td></tr>";
for($j = 1; $j <= $noOfItems; $j++){
echo "<tr><td align=left>Item Code ".$j."; </td><td align=right>".$_SESSION["ItemCode".$j]."</td></tr>";
echo "<tr><td align=left>Quantity ".$j."; </td><td align=right>" .$_SESSION["Quantity".$j]."</td></tr>";
echo "<tr><td align=left>Price ".$j."; </td><td align=right>" .$_SESSION["PricePerItem".$j]."</td></tr>";
echo "<tr><td colspan=2 align=center>--------------------------------</td></tr>";
}
echo "<tr><td align=left>P&P: </td><td align = right>".$postPack. "</td></tr>";
echo "<tr><td align=left>Payment Method: </td><td align=right>".$payMeth."</td></tr>";
echo "<tr><td align=left>PayPal Fee: </td><td align=right>".$paypal. "</td></tr>";
echo "<tr><td align=left>Additional Info: </td><td align=right>".$addInfo."</td></tr>";
echo "<tr><td colspan='2' align=center><a href='newSale.php'><button name='addAnother'>Add Another</button></a>";
echo "<a href='mainpage.php'><button name='main'>Mainpage</button></a></td></tr></table>";
echo "</div>";
}else{
echo "An error has occured!";
}
}
Anyway, no matter what, i dont get ANY of the echo'd code come through. However, the functions are carried out as normal, and the records are added to the database even though the functions are within the same if statement as the echoes
Can anyone give me some insight into this please?
thanks in advance!
Josh