Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> 2 Mysql Operations Cause Delay?
leiaah
post Feb 4 2006, 02:33 PM
Post #1


Super Member
*********

Group: Members
Posts: 436
Joined: 21-January 05
From: Koronadal City, Philippines
Member No.: 3,358



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. wink.gif Thanks.

QUOTE
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());
}
}

Go to the top of the page
 
+Quote Post
Yarrgh
post Feb 6 2006, 03:38 AM
Post #2


Newbie [Level 1]
*

Group: Members
Posts: 21
Joined: 6-February 06
Member No.: 18,277



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

CODE
<?php

// All of your code

exit; // Halts your code so it doesn't keep doing stuff.

?>


This post has been edited by Yarrgh: Feb 6 2006, 03:38 AM
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Delphi 2005 + Mysql(2)
  2. Cheat Sheets(4)
  3. What Is A Blob (mysql)(4)
  4. Mysql Changing Date Format(3)


 



- Lo-Fi Version Time is now: 13th October 2008 - 02:35 AM