Hello everybody, I can’t seem to figure out why this insert code isn’t working. I’m trying to create a database of US zip codes. I created this user interface (form) with nothing but a submit button to execute the insert query[php]
<div id="right_content" class="">
<h3> Insert Zips </h3>
<form action = "insertzip1.php" method = "post">
<input type = "submit" name = "submit" value = "submit"/>
</form>
</div> <!--closes right content-->
[/php]
Well here is the insert query which is supposed to accomplish the task. I have just included a tiny subsets of all the zipcodes (the insertzip1.php page which is the value of the action attribute of the form).
[php]
<php?
if (isset($_POST[‘submit’])) {
require (‘config.php’);
$query = "INSERT INTO zips (zip, lat, lon, city, state, county, z_type, xaxis, yaxis, zaxis, z_primary, worldregion, country, locationtext, location, population, housingunits, income, landarea, waterarea, decommisioned, militaryrestrictioncodes, decommisionedplace) VALUES
(‘00501’, 40.81, -73.04, ‘HOLTSVILLE’, ‘NY’, ‘SUFFOLK’, ‘UNIQUE’, 0.22, -0.72, 0.65, ‘Yes’, ‘NA’, ‘US’, ‘Holtsville, NY’, ‘NA-US-NY-HOLTSVILLE’, ‘’, 0, 0, ‘’, ‘’, ‘No’, ‘’, ‘’),
(‘00501’, 40.81, -73.04, ‘I R S SERVICE CENTER’, ‘NY’, ‘SUFFOLK’, ‘UNIQUE’, 0.22, -0.72, 0.65, ‘No’, ‘NA’, ‘US’, ‘I R S Service Center, NY’, ‘NA-US-NY-I R S SERVICE CENTER’, ‘’, 0, 0, ‘’, ‘’, ‘No’, ‘’, ‘’),
(‘00544’, 40.81, -73.04, ‘HOLTSVILLE’, ‘NY’, ‘SUFFOLK’, ‘UNIQUE’, 0.22, -0.72, 0.65, ‘Yes’, ‘NA’, ‘US’, ‘Holtsville, NY’, ‘NA-US-NY-HOLTSVILLE’, ‘’, 0, 0, ‘’, ‘’, ‘No’, ‘’, ‘’),
(‘00544’, 40.81, -73.04, ‘IRS SERVICE CENTER’, ‘NY’, ‘SUFFOLK’, ‘UNIQUE’, 0.22, -0.72, 0.65, ‘No’, ‘NA’, ‘US’, ‘Irs Service Center, NY’, ‘NA-US-NY-IRS SERVICE CENTER’, ‘’, 0, 0, ‘’, ‘’, ‘No’, ‘’, ‘’)
";
$result = mysql_query($query);
header(“Location: insertzipsuccess.php”);
}else{ die (“Could not insert data because” . mysql_error());}
?>
[/php]
The insertzipsuccess.php page is simply a page that prints out a success message if the query is successfully executed. Well when I hit the submit button, I just get redirected to a blank insertzip1.php page
Can anyone show me what I’m not doing right here?
PS I already created the table with fields that correspond to all the fields I’m trying insert.