I've been trying to use radio buttons on my form. It worked perfectly fine before adding the radio buttons but now I'm getting the following error:
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''pay_for_insurance', 'dont_pay_for_insurance', 'self_employed', 'not_self_employ' at line 1
Please help! The two source files are located below
<?php
$con = mysql_connect ("localhost", "xxx", "xxx") or die ('I cannot connect to the database because: ' . mysql_error());
$db = mysql_select_db ("insurance", $con);
require 'variables.php';
$sql = "INSERT INTO `insurance`.`info` (`firstname`, `lastname`, `address`, `city`, `state`, `birthdate`, `telephone`, `email`, 'pay_for_insurance', 'dont_pay_for_insurance', 'self_employed', 'not_self_employed', 'has_health_insurance', 'no_health_insurance', 'has_cobra', 'no_cobra', 'current_ins', 'employees', 'dep1', 'dep2', 'dep3', 'smoker', 'non_smoker', 'health', 'life', 'dental')
VALUES ('$firstname', '$lastname', '$address', '$city', '$state', '$zipcode', '$birthdate', '$telephone', '$email', '$pay_for_insurance', '$dont_pay_for_insurance', '$self_employed', '$not_self_employed', '$has_health_insurance', '$no_health_insurance', '$has_cobra', '$no_cobra', '$current_ins', '$employees', '$dep1', '$dep2', '$dep3', '$smoker', '$non_smoker', '$health', '$life', '$dental')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
?>
<?php
$ID = mysql_real_escape_string($_POST['ID']);
$firstname = mysql_real_escape_string($_POST['firstname']);
$lastname = mysql_real_escape_string($_POST['lastname']);
$address = mysql_real_escape_string($_POST['address']);
$city = mysql_real_escape_string($_POST['city']);
$state = mysql_real_escape_string($_POST['state']);
$birthdate = mysql_real_escape_string($_POST['birthdate']);
$telephone = mysql_real_escape_string($_POST['telephone']);
$pay_for_insurance = mysql_real_escape_string($_POST['pay_for_insurance']);
$dont_pay_for_insurance = mysql_real_escape_string($_POST['dont_pay_for_insurance']);
$self_employed = mysql_real_escape_string($_POST['self_employed']);
$not_self_employed = mysql_real_escape_string($_POST['not_self_employed']);
$has_health_insurance = mysql_real_escape_string($_POST['has_health_insurance']);
$no_health_insurance = mysql_real_escape_string($_POST['no_health_insurance']);
$has_cobra = mysql_real_escape_string($_POST['has_cobra']);
$no_cobra = mysql_real_escape_string($_POST['no_cobra']);
$current_ins = mysql_real_escape_string($_POST['current_ins']);
$employees = mysql_real_escape_string($_POST['employees']);
$dep1 = mysql_real_escape_string($_POST['dep1']);
$dep2 = mysql_real_escape_string($_POST['dep2']);
$dep3 = mysql_real_escape_string($_POST['dep3']);
$smoker = mysql_real_escape_string($_POST['smoker']);
$non_smoker = mysql_real_escape_string($_POST['non_smoker']);
$health = mysql_real_escape_string($_POST['health']);
$life = mysql_real_escape_string($_POST['life']);
$dental = mysql_real_escape_string($_POST['dental']);
?>
PHP FORM:
<form name="form" method="POST" action="final.php">
<h3>Personal Information</h3>
First Name
<input type="text" name="firstname" id="firstname" />
<p>Last Name
<input type="text" name="lastname" id="lastname" />
</p>
<p>Address
<input type="text" name="address" id="address" />
<p>City
<input type="text" name="city" id="city" />
</p>
<p>State
<input type="text" name="state" id="state" />
</p>
<p>Zip Code
<input type="text" name="zipcode" id="zipcode" />
</p>
<p>Birthdate
<input type="text" name="birthdate" id="birthdate" />
</p>
<h3>Contact Information</h3>
<p>Telephone Number
<input type="text" name="telephone" id="telephone" />
</p>
<p>Email
<input type="text" name="email" id="email" />
</p>
<h3>Health Questions</h3>
<p>1. Are you responsible for obtaining and paying for your health insurance?
<br />
<input type="radio" name="group1" id="pay_for_insurance" value="pay_for_insurance">
Yes
<input type="radio" name="group1" id="dont_pay_for_insurance" value="dont_pay_for_insurance">
No<br />
</p>
<p>2. Are you self employed?<br />
<input type="radio" name="group2" id="self_employed" value="self_employed">
Yes
<input type="radio" name="group2" id="not_self_employed" value="not_self_employed">
No<br />
</p>
<p>3. Do you currently have health insurance?
<br />
<input type="radio" name="group3" id="has_health_insurance" value="has_health_insurance">
Yes
<input type="radio" name="group3" id="no_health_insurance" value="no_health_insurance">
No<br />
</p>
<p>4. Are you currently covered by Cobra?
<br />
<input type="radio" name="group4" id="has_cobra" value="has_cobra">
Yes
<input type="radio" name="group4" id="no_cobra" value="no_cobra">
No</p>
<p>5. What is the name of your current insurance company?
<input type="text" name="current_ins" id="current_ins" />
</p>
<p>6. Number of full-time employees
<input type="text" name="employees" id="employees" />
</p>
<p>7. Age of dependants
<br />
•<input type="text" name="dep1" id="dep1" /><br />
•<input type="text" name="dep2" id="dep2" /><br />
•<input type="text" name="dep3" id="dep3" />
</p>
<p>8. Are you a tobacco user?
<br />
<input type="radio" name="group5" id="smoker" value="smoker">
Yes
<input type="radio" name="group5" id="non_smoker" value="non_smoker">
No<br />
</p>
<p>Yes, I am interested in:
<br />
<input type="checkbox" name="insurance[]" id="health" value="health">
Health Insurance
<br />
<input type="checkbox" name="insurance[]" id="life" value="life">
Life Insurance
<br />
<input type="checkbox" name="insurance[]" id="dental" value="dental">
Dental Insurance
<br />
<p>
<input type="submit" name="submit" value="Submit" id="submit" />
</p>
</form>