GOLDfish_74 Posted June 11, 2007 Share Posted June 11, 2007 I have made this page to change the values of the table "stock_levels" when products are received. I have yet to put any information in the tables in question just to make sure it will say any errors. But this script is returning no errors. Can someone help me clean up the script and find out why it reports no errors. <html> <head> <link href="../style.css" rel="stylesheet" type="text/css" /> </head> <? if (isset($_POST['submit'])){ if(!isset($_POST['qty'])){ echo('You have not filled out the required field "Quantity."'); exit(); } if (isset($_POST['ean'])){ $ean = ($_POST['ean']); $getdetail = mysql_query("SELECT item_id, item_fullname, item_description FROM item_details WHERE item_ean='$ean'") or die(print (mysql_error)); $row = mysql_fetch_assoc($getdetail); $itemid = ($row['item_id']); $itemname = ($row['item_fullname']); $desc = ($row['item_description']); } elseif (isset($_POST['model'])){ $model = ($_POST['model']); $getdetail = mysql_query("SELECT item_id, item_fullname, item_description FROM item_details WHERE item_trunname='$model' OR item_fullname='$model'") or die(print (mysql_error)); $row = mysql_fetch_assoc($getdetail); $itemid = ($row['item_id']); $itemname = ($row['item_fullname']); $desc = ($row['item_description']); } else { echo('An error has occured, not all fields were entered correctly. Please press the back button on your browser to try again.'); exit(); } $qty = ($_POST['qty']); if (is_numeric($qty)==false){ echo("Quantity can only be entered as whole number amounts."); exit(); } $setting = mysql_query("SELECT stock_soo, stock_soh FROM stock_levels WHERE stock_item_id='$itemid'"); $rows = mysql_fetch_assoc($setting); $soo = ($rows['stock_soo'] - $qty); $soh = ($rows['stock_soh'] + $qty); $entry = mysql_query("UPDATE stock_levels SET stock_soh='$soh', stock_soo='$soo' WHERE stock_item_id='$itemid'") or die(print (mysql_error)); } else { ?> <body> <form method="post" action="srs.php?p=1]" class="bgeneral"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="2"><span class="title">Receive Order</span><br /> </td> </tr> <tr> <td align="right">EAN:</td> <td><input type="text" name="ean" accesskey="e" tabindex="0"></td> </tr> <tr> <td colspan="2" align="center"><br> or;<br> </td> </tr> <tr> <td align="right">Model #:</td> <td><input type="text" name="model" accesskey="w" tabindex="1"></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td align="right">Amount Recieved:</td> <td><input type="text" name="qty" accesskey="q" tabindex="2"></td> </tr> <tr> <td> </td> <td> <br /><input type="submit" name="submit" value="submit" /></td> </tr> </table> </form> <? } ?> </body> </html> Thanks anyone, Regards, THEfish! Quote Link to comment https://forums.phpfreaks.com/topic/55178-need-help-cleaning-script-and-finding-errors/ Share on other sites More sharing options...
lighton Posted June 12, 2007 Share Posted June 12, 2007 perhaps because the php code is not in the body of the page, you have it somewhere between the end of head and beginning of body. also why have you brackets with echo e.g. echo() just write echo 'some stuff'; Quote Link to comment https://forums.phpfreaks.com/topic/55178-need-help-cleaning-script-and-finding-errors/#findComment-273016 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.