multiple record

can't save multiple record

Page 1 of 1

1 Replies - 671 Views - Last Post: 25 March 2010 - 06:36 AM Rate Topic: -----

#1 raven21   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 34
  • Joined: 28-July 09

multiple record

Posted 25 March 2010 - 12:23 AM

Hi guys,

Would like to ask for help, I've been doing this for a week. and I still don't get the right code in order for it to run.
I would like to insert multiple records in database, but what happen is that it only saves one entry and the rest was gone.
here's the code:

	
	
	if(!error){ 
   	 $query = "INSERT INTO ffeequip (brand, type,model,emp_id,create_date,category,serial,created_by)
                   VALUES (ucase('$brand'),ucase('$type'),ucase('$model'),ucase('$owner'),NOW(),ucase('$category'),ucase('$serial'),'$empid')";
	    	  $result = @mysql_query($query);
	 	      $mast_id = mysql_insert_id();
         if ($result) {
	    // save to ffeemp table if employee name is selected
	    if ($_POST['emp_id'] <> 0) {
	       $query2 = "INSERT INTO ffeemp (emp_id,serial,create_by,create_date,transfer) 
		   VALUES ('$owner','$serial','$empid',NOW(),'N')";
           $result2 = @mysql_query($query2);
	    }

	   
	       $query2 = 'UPDATE ffeequip SET cat_id='.$cat_id.' WHERE mast_id='.$mast_id;
           $result2 = @mysql_query($query2);
 
	    }

	    $url = '?opt='.$_POST['hopt']."&key=".$_POST['hkey'];
        header ("Location:  http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/assets.php".$url);                exit();

}    
}
   // isset 



All your help will be greatly appreciated...Thank you.

Is This A Good Question/Topic? 0
  • +

Replies To: multiple record

#2 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6259
  • View blog
  • Posts: 24,028
  • Joined: 23-August 08

Re: multiple record

Posted 25 March 2010 - 06:36 AM

Novel idea: check your query calls for errors -- instead of ignoring them as you are currently -- and log them/print them somewhere.

New PHP devs appear to have this blind faith that every SQL query works automagically...I'm not sure from where that comes.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1