hansman Posted August 22, 2008 Share Posted August 22, 2008 code $zips = $_POST['zips']; $zipsextracted = explode(",", $zips); mysql_connect("-----", "--------", "------"); mysql_select_db("--------") or die( "Unable to select database"); foreach($zipsextracted as $zip) { "INSERT INTO `Zips_To_Company` (`id`, `company_id`, `zip_id`) VALUES ('', '1', '$zip')"; } echo $zipsextracted; ------Displays "array" when i turn the query into a variable it only shows the last item in the array. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 22, 2008 Share Posted August 22, 2008 You can't echo an array to begin with, so it just shows "Array" when you try to echo it. Now, what happens with the query exactly, and how is $_POST['zips'] formatted? Quote Link to comment Share on other sites More sharing options...
hansman Posted August 22, 2008 Author Share Posted August 22, 2008 $_POST['zips'] = 10567,10567...... and the query dosent even work, nothing put into the db Quote Link to comment Share on other sites More sharing options...
hansman Posted August 22, 2008 Author Share Posted August 22, 2008 $_POST['zips'] = 10567,10567...... and the query dosent even work, nothing put into the db Quote Link to comment Share on other sites More sharing options...
Jibberish Posted August 22, 2008 Share Posted August 22, 2008 Just a quick question just in case, are you actually running the query, as cant really tell from that code i.e $zips = $_POST['zips']; $zipsextracted = explode(",", $zips); mysql_connect("-----", "--------", "------"); mysql_select_db("--------") or die( "Unable to select database"); foreach($zipsextracted as $zip) { $sql = "INSERT INTO `Zips_To_Company` (`id`, `company_id`, `zip_id`) VALUES ('', '1', '$zip')"; mysql_query($sql)or die('Error, insert query failed'); } Quote Link to comment Share on other sites More sharing options...
hansman Posted August 22, 2008 Author Share Posted August 22, 2008 haha im stupid forgot to query it, thank you Quote Link to comment 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.