leiaah 0 Report post Posted February 4, 2006 I'm doing an Inventory system using PHP and MySQL. It's almost done now but I've been having a problem with this particular code. This is a function that does two things. It updates a table with edited values and then inserts values to another table. It's working fine except that the status bar of my browser indicates that the page (with this function) is still loading when in fact the function has been terminated and it did its job already (I've checked the dbase) and there's no command after calling the function. Could the delay be because I have two mysql operations here? Or is something I missed in the code? I hope this post is understood. Thanks. function edit(){ $id = $_GET['id']; $PID = $_GET['pid']; $orig = $_GET['orig']; $beg_qty = $_GET['beg_qty']; $supplier = $_GET['supplier']; $pur_price =$_GET['pur_price']; $sel_price = $_GET['sel_price']; $date_pur = $_GET['date_pur']; $exp = $_GET['exp']; @ $db = mysql_pconnect('localhost', 'xx', 'xx'); mysql_select_db('avh'); if (!$db) { echo 'Error: Could not connect to database. Please try again later.'; exit; } $query = "update Item_In_Stock set Date_Purchased='".$date_pur."', Expiration='".$exp."', Beginning_qty=".$beg_qty.",Supplier_ID='".$supplier."' where purchase_ID='".$PID."'"; $result = mysql_query($query) or die(mysql_error()); if($orig!=$sel_price){ $qry = "insert into Item_Price(Purchase_ID,Price,Price_date) values (".$PID.", ".$sel_price.",'".$date."')"; $res = mysql_query($query) or die(mysql_error()); }} Share this post Link to post Share on other sites
Yarrgh 0 Report post Posted February 6, 2006 (edited) Using mysql operations twice shouldn't do anything to the page loading. It could be the browser not disconnecting from the server? try to use "exit;" at the end of your code. If it doesn't do anything then don't worry about it. At least your code is working.Just for an example <?php // All of your code exit; // Halts your code so it doesn't keep doing stuff.?> Edited February 6, 2006 by Yarrgh (see edit history) Share this post Link to post Share on other sites