cmaclennan Posted May 14, 2009 Share Posted May 14, 2009 Hi Guys, I have a form i'm trying to use to submit data to 2 seperate tables and i keep getting errors and i have no idea why as i have only slightly modified the query from another one i have used succesfully, if someone can take a look at it for me and let me know what im missing it would be a huge help. // Make the query. $query = "INSERT INTO rma (rma_id, date, store_company, city, address, address2, state_prov, zip_postal, country, phone, ext, contact) VALUES ('$ri', '$dt', '$co', '$ct' , '$ad', '$ad2', '$sp', '$zp', '$cou', '$ph', '$ex', '$cn')"; $result = @mysql_query ($query); // Run the query. $rma_id = mysql_insert_id(); $result = @mysql_query ($query); // Run the query. foreach($_POST as $key => $value) { //looping through all posted fields if(strpos($key, 'item_') !== false) { //found a part field, need to find out the _x number, then insert the entire row $suffix = substr($key, -1); //this gets the _x number $item = $_POST['item_' . $suffix]; $description = $_POST['description_' . $suffix]; $qty = $_POST['qty_' . $suffix]; $serial = $_POST['serial_' . $suffix]; $mfg = $_POST['mfg_' . $suffix]; $tariff = $_POST['tariff_' . $suffix]; $value = $_POST['value_' . $suffix]; $query = "INSERT INTO rma_parts (id, item, description, qty, serial, mfg, tariff, value, rma_id) VALUES ('', '$item', '$description', '$qty', '$serial', '$mfg', '$tariff', 'value', '$rma_id')"; $result = mysql_query($query); } } if ($result) { // If it ran OK. Quote Link to comment https://forums.phpfreaks.com/topic/158059-desperate-for-some-help/ Share on other sites More sharing options...
Cosizzle Posted May 14, 2009 Share Posted May 14, 2009 add this if if (!$result) { die('Invalid query: ' . mysql_error()); } do you get an error message? Quote Link to comment https://forums.phpfreaks.com/topic/158059-desperate-for-some-help/#findComment-833763 Share on other sites More sharing options...
sqlnoob Posted May 14, 2009 Share Posted May 14, 2009 are the tables within the same database? Quote Link to comment https://forums.phpfreaks.com/topic/158059-desperate-for-some-help/#findComment-833906 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.