我正在处理一个将选择选项值发布到我的数据库的表单。我已经完成了 Dreamweaver 服务器行为的所有代码,但仍然无法正常工作。这是 HTML 和 PHP 代码。
任何帮助表示赞赏
<form method="POST" action="<?php echo $editFormAction; ?>" name="applynow">
<table width="550" border="0">
<tr><h4>Name *</h4>
<td width="264"><input name="fname" type="text" size="30" maxlength="35" placeholder="First Name"/></td>
<td width="276"><input name="lname" type="text" size="30" maxlength="35" placeholder="Last Name"/></td>
</tr>
</table>
<p>
<label>
<input type="radio" name="gender" value="male" id="male" />
Male</label>
<br />
<label>
<input type="radio" name="gender" value="female" id="female" />
Female</label>
<br />
</p>
</table>
<table width="550" border="0">
<tr>
<h4>Address *</h4><p><input style="width:485px" name="address_1" type="text" size="30" maxlength="30" placeholder="Street Address"/>
</tr>
<tr>
<input style="width:485px" name="address_2" type="text" size="30" maxlength="30" placeholder="Address Line 2"/>
</tr>
</table>
<table width="550" border="0">
<tr>
<td><input name="city" type="text" size="30" maxlength="30" placeholder="City"/></td>
<td><input name="state" type="text" size="30" maxlength="30" placeholder="State / Province / Region"/></td>
</tr>
<tr>
<td><input name="zipcode" type="text" size="30" maxlength="30" placeholder="Zip / Postal Code"/></td>
<td>
<select style="width:223px" name='Country' tabindex='12' id="Country" >
<option value="Not Selected">Select you country</option>
<option value='Afghanistan' >Afghanistan</option>
<option value='Albania'>Albania</option>
<option value='Algeria' >Algeria</option>
<option value='American Samoa' >American Samoa</option>
<option value='Andorra' >Andorra</option>
<option value='Angola' >Angola</option>
<option value='Antigua and Barbuda' >Antigua and Barbuda</option>
<option value='Argentina' >Argentina</option>
<option value='Armenia' >Armenia</option>
<option value='Australia' >Australia</option>
<option value='Austria' >Austria</option>
<option value='Azerbaijan' >Azerbaijan</option>
<option value='Bahamas' >Bahamas</option>
<option value='Bahrain' >Bahrain</option>
<option value='Bangladesh' >Bangladesh</option>
<option value='Barbados' >Barbados</option>
<option value='Belarus' >Belarus</option>
<option value='Belgium' >Belgium</option>
<option value='Belize' >Belize</option>
<option value='Benin' >Benin</option>
<option value='Bermuda' >Bermuda</option>
<option value='Bhutan' >Bhutan</option>
<option value='Bolivia' >Bolivia</option>
<option value='Bosnia and Herzegovina' >Bosnia and Herzegovina</option>
<option value='Botswana' >Botswana</option>
<option value='Brazil' >Brazil</option>
<option value='Brunei' >Brunei</option>
<option value='Bulgaria' >Bulgaria</option>
<option value='Burkina Faso' >Burkina Faso</option>
<option value='Burundi' >Burundi</option>
<option value='Cambodia' >Cambodia</option>
<option value='Cameroon' >Cameroon</option>
<option value='Canada' >Canada</option>
<option value='Cape Verde' >Cape Verde</option>
<option value='Central African Republic' >Central African Republic</option>
<option value='Chad' >Chad</option>
<option value='Chile' >Chile</option>
<option value='China' >China</option>
<option value='Colombia' >Colombia</option>
<option value='Comoros' >Comoros</option>
<option value='Congo, Democratic Republic of the' >Congo, Democratic Republic of the</option>
<option value='Congo, Republic of the' >Congo, Republic of the</option>
<option value='Costa Rica' >Costa Rica</option>
<option value='Côte d'Ivoire' >Côte d'Ivoire</option>
<option value='Croatia' >Croatia</option>
<option value='Cuba' >Cuba</option>
<option value='Cyprus' >Cyprus</option>
<option value='Czech Republic' >Czech Republic</option>
<option value='Denmark' >Denmark</option>
<option value='Djibouti' >Djibouti</option>
<option value='Dominica' >Dominica</option>
<option value='Dominican Republic' >Dominican Republic</option>
<option value='East Timor' >East Timor</option>
<option value='Ecuador' >Ecuador</option>
<option value='Egypt' >Egypt</option>
<option value='El Salvador' >El Salvador</option>
<option value='Equatorial Guinea' >Equatorial Guinea</option>
<option value='Eritrea' >Eritrea</option>
<option value='Estonia' >Estonia</option>
<option value='Ethiopia' >Ethiopia</option>
<option value='Fiji' >Fiji</option>
<option value='Finland' >Finland</option>
<option value='France' >France</option>
<option value='Gabon' >Gabon</option>
<option value='Gambia' >Gambia</option>
<option value='Georgia' >Georgia</option>
<option value='Germany' >Germany</option>
<option value='Ghana' >Ghana</option>
<option value='Greece' >Greece</option>
<option value='Greenland' >Greenland</option>
<option value='Grenada' >Grenada</option>
<option value='Guam' >Guam</option>
<option value='Guatemala' >Guatemala</option>
<option value='Guinea' >Guinea</option>
<option value='Guinea-Bissau' >Guinea-Bissau</option>
<option value='Guyana' >Guyana</option>
<option value='Haiti' >Haiti</option>
<option value='Honduras' >Honduras</option>
<option value='Hong Kong' >Hong Kong</option>
<option value='Hungary' >Hungary</option>
<option value='Iceland' >Iceland</option>
<option value='India' >India</option>
<option value='Indonesia' >Indonesia</option>
<option value='Iran' >Iran</option>
<option value='Iraq' >Iraq</option>
<option value='Ireland' >Ireland</option>
<option value='Israel' >Israel</option>
<option value='Italy' >Italy</option>
<option value='Jamaica' >Jamaica</option>
<option value='Japan' >Japan</option>
<option value='Jordan' >Jordan</option>
<option value='Kazakhstan' >Kazakhstan</option>
<option value='Kenya' >Kenya</option>
<option value='Kiribati' >Kiribati</option>
<option value='North Korea' >North Korea</option>
<option value='South Korea' >South Korea</option>
<option value='Kuwait' >Kuwait</option>
<option value='Kyrgyzstan' >Kyrgyzstan</option>
<option value='Laos' >Laos</option>
<option value='Latvia' >Latvia</option>
<option value='Lebanon' >Lebanon</option>
<option value='Lesotho' >Lesotho</option>
<option value='Liberia' >Liberia</option>
<option value='Libya' >Libya</option>
<option value='Liechtenstein' >Liechtenstein</option>
<option value='Lithuania' >Lithuania</option>
<option value='Luxembourg' >Luxembourg</option>
<option value='Macedonia' >Macedonia</option>
<option value='Madagascar' >Madagascar</option>
<option value='Malawi' >Malawi</option>
<option value='Malaysia' >Malaysia</option>
<option value='Maldives' >Maldives</option>
<option value='Mali' >Mali</option>
<option value='Malta' >Malta</option>
<option value='Marshall Islands' >Marshall Islands</option>
<option value='Mauritania' >Mauritania</option>
<option value='Mauritius' >Mauritius</option>
<option value='Mexico' >Mexico</option>
<option value='Micronesia' >Micronesia</option>
<option value='Moldova' >Moldova</option>
<option value='Monaco' >Monaco</option>
<option value='Mongolia' >Mongolia</option>
<option value='Montenegro' >Montenegro</option>
<option value='Morocco' >Morocco</option>
<option value='Mozambique' >Mozambique</option>
<option value='Myanmar' >Myanmar</option>
<option value='Namibia' >Namibia</option>
<option value='Nauru' >Nauru</option>
<option value='Nepal' >Nepal</option>
<option value='Netherlands' >Netherlands</option>
<option value='New Zealand' >New Zealand</option>
<option value='Nicaragua' >Nicaragua</option>
<option value='Niger' >Niger</option>
<option value='Nigeria' >Nigeria</option>
<option value='Norway' >Norway</option>
<option value='Northern Mariana Islands' >Northern Mariana Islands</option>
<option value='Oman' >Oman</option>
<option value='Pakistan' >Pakistan</option>
<option value='Palau' >Palau</option>
<option value='Palestine' >Palestine</option>
<option value='Panama' >Panama</option>
<option value='Papua New Guinea' >Papua New Guinea</option>
<option value='Paraguay' >Paraguay</option>
<option value='Peru' >Peru</option>
<option value='Philippines' >Philippines</option>
<option value='Poland' >Poland</option>
<option value='Portugal' >Portugal</option>
<option value='Puerto Rico' >Puerto Rico</option>
<option value='Qatar' >Qatar</option>
<option value='Romania' >Romania</option>
<option value='Russia' >Russia</option>
<option value='Rwanda' >Rwanda</option>
<option value='Saint Kitts and Nevis' >Saint Kitts and Nevis</option>
<option value='Saint Lucia' >Saint Lucia</option>
<option value='Saint Vincent and the Grenadines' >Saint Vincent and the Grenadines</option>
<option value='Samoa' >Samoa</option>
<option value='San Marino' >San Marino</option>
<option value='Sao Tome and Principe' >Sao Tome and Principe</option>
<option value='Saudi Arabia' >Saudi Arabia</option>
<option value='Senegal' >Senegal</option>
<option value='Serbia and Montenegro' >Serbia and Montenegro</option>
<option value='Seychelles' >Seychelles</option>
<option value='Sierra Leone' >Sierra Leone</option>
<option value='Singapore' >Singapore</option>
<option value='Slovakia' >Slovakia</option>
<option value='Slovenia' >Slovenia</option>
<option value='Solomon Islands' >Solomon Islands</option>
<option value='Somalia' >Somalia</option>
<option value='South Africa' >South Africa</option>
<option value='Spain' >Spain</option>
<option value='Sri Lanka' >Sri Lanka</option>
<option value='Sudan' >Sudan</option>
<option value='Sudan, South' >Sudan, South</option>
<option value='Suriname' >Suriname</option>
<option value='Swaziland' >Swaziland</option>
<option value='Sweden' >Sweden</option>
<option value='Switzerland' >Switzerland</option>
<option value='Syria' >Syria</option>
<option value='Taiwan' >Taiwan</option>
<option value='Tajikistan' >Tajikistan</option>
<option value='Tanzania' >Tanzania</option>
<option value='Thailand' >Thailand</option>
<option value='Togo' >Togo</option>
<option value='Tonga' >Tonga</option>
<option value='Trinidad and Tobago' >Trinidad and Tobago</option>
<option value='Tunisia' >Tunisia</option>
<option value='Turkey' >Turkey</option>
<option value='Turkmenistan' >Turkmenistan</option>
<option value='Tuvalu' >Tuvalu</option>
<option value='Uganda' >Uganda</option>
<option value='Ukraine' >Ukraine</option>
<option value='United Arab Emirates' >United Arab Emirates</option>
<option value='United Kingdom' >United Kingdom</option>
<option value='United States' >United States</option>
<option value='Uruguay' >Uruguay</option>
<option value='Uzbekistan' >Uzbekistan</option>
<option value='Vanuatu' >Vanuatu</option>
<option value='Vatican City' >Vatican City</option>
<option value='Venezuela' >Venezuela</option>
<option value='Vietnam' >Vietnam</option>
<option value='Virgin Islands, British' >Virgin Islands, British</option>
<option value='Virgin Islands, U.S.' >Virgin Islands, U.S.</option>
<option value='Yemen' >Yemen</option>
<option value='Zambia' >Zambia</option>
<option value='Zimbabwe' >Zimbabwe</option>
</select>
</td>
</tr>
<tr>
<td>
<h4>Phone *</h4><p>
<input name="day_phone" type="text" size="30" maxlength="30" />
</td>
<td>
<h4>Email</h4><p>
<input name="email" type="text" size="30" maxlength="30" />
</td>
</tr>
<tr>
<td colspan="2">
<h4>Study number or name you are interested in</h4>
<p>
<input name="study" style="width:400px" type="text" size="30" maxlength="30" />
</td>
</tr>
<tr>
<td colspan="2">
<h4>Language *</h4><p>
<select name="language" style="width:220px">
<option value="English">English</option>
<option value="Español" >Español</option>
<option value="Other">Other</option>
</select>
<tr>
<td colspan="2">
<h4>Are you interested in a specific study?<p>
<select name="specific-study" style="width:220px">
<option value="Gout">Gout RDEA594-301</option>
<option value="Diabetes">Diabetes TYPE II OMNEON-018</option>
<option value="COPD">COPD PT-003007</option>
</select>
<tr>
<td colspan="2">
<h4>How did you hear about us?</h4><p>
<select name='referral' style="width:220px">
<option value='internet' >Internet</option>
<option value='newspaper'>Newspaper</option>
<option value='magazine'>Magazine</option>
<option value='radio'>Radio</option>
<option value='tv'>Television</option>
<option value='doctor'>Doctor</option>
<option value='friend'>Friend</option>
<option value='family-member'>Family Member</option>
<option value='s-s'>Spouse/Significant Other</option>
<option value='other'>Other</option>
</select>
</td>
</tr>
<tr>
<td colspan="2">
<h4>Date of Birth *</h4><p>
<input type="text" name="birthdate" placeholder="MM/DD/YYYY"/>
</td>
</tr>
</table>
<div class="tail2"><h4>SECTION 2: PARTICIPANT INFORMATION</h4></div>
<h4>When are you available for overnight stays? *</h4>
<p>
<label>
<input type="checkbox" name="overnight-stay" value="anytime" id="anytime" />
Anytime</label>
<br />
<label>
<input type="checkbox" name="overnight-stay" value="weekends" id="weekends" />
Weekends</label>
<br />
<label>
<input type="checkbox" name="overnight-stay" value="weekdays" id="weekdays" />
Weekdays</label>
<br />
<label>
<input type="checkbox" name="overnight-stay" value="outpatient" id="outpatient" />
Outpatient Only</label>
<br />
<label>
<input type="checkbox" name="overnight-stay" value="shortStaysOnly" id="shortStaysOnly" />
Short Stays Only</label>
<br />
<label>
<input type="checkbox" name="overnight-stay" value="longStaysOnly" id="longStaysOnly" />
Long Stays Only</label>
<br />
</p>
<h4>Smoking Status *</h4>
<p>
<label>
<input type="radio" name="smoking" value="none" id="none" />
None (no nicotine w/in the last 90 days)</label>
<br />
<label>
<input type="radio" name="smoking" value="1-10/day" id="1-10/day" />
1 to 10 Cigarettes/Day</label>
<br />
<label>
<input type="radio" name="smoking" value="11-20/day" id="11-20/day" />
11 to 20 Cigarettes/Day</label>
<br />
<label>
<input type="radio" name="smoking" value="21+/day" id="21+/day" />
21 or more Cigarettes/Day</label>
<br />
<label>
<input type="radio" name="smoking" value="occasional-social" id="occasional-social" />
Occasional Smoker/Social Smoker</label>
<br />
<label>
<input type="radio" name="smoking" value="other" id="other" />
Other</label>
<br />
</p>
<h4>Taking any Prescriptions or Medicines *</h4><p>
<textarea style="width:535px; height:100px" name="scripts" cols="150" rows="10"></textarea>
<p style="font-size:10px; margin-top:-30px">Please list any prescription or over-the-counter medication you have taken within the last 30 days (Including birth control, vitamins, herbal supplements). If you have not taken any prescription or over-the-counter drugs in the past 30 days, type None.</p>
<h4>Allergies? *</h4><p>
<textarea style="width:535px; height:100px" name="allergies" cols="150" rows="20"></textarea>
<p style="font-size:10px; margin-top:-30px">If you are allergic to medications, please list what they are, and the reaction you have to the medication (e.g. Penicillin: rash, Codeine: swelling). You do no not have any alleriges, type None.</p>
<h4>Medical Conditions? *</h4><p>
<textarea style="width:535px; height:100px" name="medcond" cols="150" rows="20"></textarea>
<p style="font-size:10px; margin-top:-30px">Please list any chronic medical conditions or diagnosis (e.g. asthma, diabetes, high blood pressure, depression, etc.) If you do not have any chronic medical conditions, type None.</p>
<h4>Dietary Needs? *</h4><p>
<textarea style="width:535px; height:100px" name="dietneeds" cols="150" rows="20"></textarea>
<p style="font-size:10px; margin-top:-30px">Please list any special dietary needs (e.g. vegetarian, lactose intolerant, diabetic). If you do not have any special dietary needs, type None.</p>
<h4>If Vegetarian/Vegen/Lactose, would you be willing to eat meat/dairy if the study required it?*</h4>
<p>
<label>
<input type="radio" name="ifvegan" value="yes" id="yes" />
Yes</label>
<br />
<label>
<input type="radio" name="ifvegan" value="no" id="no" />
No</label>
<br />
<label>
<input type="radio" name="ifvegan" value="na" id="na" />
Not Applicable</label>
<br />
</p>
<h4>Do you have (please check all that apply)? *</h4>
<p>
<label>
<input type="checkbox" name="conditions" value="h-a" id="CheckboxGroup1_0" />
Hepatitis A</label>
<br />
<label>
<input type="checkbox" name="conditions" value="h-b" id="CheckboxGroup1_1" />
Hepatitis B</label>
<br />
<label>
<input type="checkbox" name="conditions" value="h-c" id="CheckboxGroup1_2" />
Hepatitis C</label>
<br />
<label>
<input type="checkbox" name="conditions" value="hiv" id="CheckboxGroup1_3" />
HIV</label>
<br />
<label>
<input type="checkbox" name="conditions" value="none" id="CheckboxGroup1_4" />
None of the above</label>
<br />
</p>
<h4>Have you used any illicit drugs in the past year? *</h4>
<p>
<label>
<input type="radio" name="drugs" value="yes" id="drugs_0" />
Yes</label>
<br />
<label>
<input type="radio" name="drugs" value="no" id="drugs_1" />
No</label>
<br />
</p>
<h4>Height *</h4><p>
<input name="height" type="text" size="30" maxlength="30" />
<h4>Weight *</h4><p>
<input name="weight" type="text" size="30" maxlength="30" />
<h4>What would you classify your race as? *</h4>
<p>
<label>
<input type="radio" name="race" value="African American/Black" id="race_0" />
African American/Black</label>
<br />
<label>
<input type="radio" name="race" value="American Eskimo" id="race_1" />
American Eskimo</label>
<br />
<label>
<input type="radio" name="race" value="Asian" id="race_2" />
Asian</label>
<br />
<label>
<input type="radio" name="race" value="Caucasian" id="race_3" />
Caucasian</label>
<br />
<label>
<input type="radio" name="race" value="Hispanic" id="race_4" />
Hispanic</label>
<br />
<label>
<input type="radio" name="race" value="Latino" id="race_5" />
Latino</label>
<br />
<label>
<input type="radio" name="race" value="Middle Eastern" id="race_6" />
Middle Eastern</label>
<br />
<label>
<input type="radio" name="race" value="Native American" id="race_7" />
Native American</label>
<br />
<label>
<input type="radio" name="race" value="Pacific Islander" id="race_8" />
Pacific Islander</label>
<br />
<label>
<input type="radio" name="race" value="Other" id="race_9" />
Other</label>
<br />
</p>
<h4>Can we retain this information in our confidential database? *</h4>
<p>
<label>
<input type="radio" name="retain-info" value="yes" id="retain-info_0" />
Yes</label>
<br />
<label>
<input type="radio" name="retain-info" value="no" id="retain-info_1" />
No</label>
<br />
</p>
<h4>Comments</h4><p>
<textarea name="comments" cols="1" rows="4" style="width:530px"></textarea>
<input name="submit" type="submit" value="Submit" />
<input type="hidden" name="MM_insert" value="applynow" />
</form>
<?php require_once('../Connections/conn_db.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "applynow")) {
$insertSQL = sprintf("INSERT INTO study_applications (fname, lname, gender, address_1, address_2, city, `state`, zipcode, country, day_phone, email, study, `language`, specific-study, referral, birthdate, overnight-stay, smoking, scripts, allergies, medcond, dietneeds, ifvegan, conditions, drugs, height, weight, race, retain-info, comments) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['fname'], "text"),
GetSQLValueString($_POST['lname'], "text"),
GetSQLValueString($_POST['gender'], "text"),
GetSQLValueString($_POST['address_1'], "text"),
GetSQLValueString($_POST['address_2'], "text"),
GetSQLValueString($_POST['city'], "text"),
GetSQLValueString($_POST['state'], "text"),
GetSQLValueString($_POST['zipcode'], "text"),
GetSQLValueString($_POST['Country'], "text"),
GetSQLValueString($_POST['day_phone'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['study'], "text"),
GetSQLValueString($_POST['language'], "text"),
GetSQLValueString($_POST['specific-study'], "text"),
GetSQLValueString($_POST['referral'], "text"),
GetSQLValueString($_POST['birthdate'], "text"),
GetSQLValueString(isset($_POST['overnight-stay']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString($_POST['smoking'], "text"),
GetSQLValueString($_POST['scripts'], "text"),
GetSQLValueString($_POST['allergies'], "text"),
GetSQLValueString($_POST['medcond'], "text"),
GetSQLValueString($_POST['dietneeds'], "text"),
GetSQLValueString($_POST['ifvegan'], "text"),
GetSQLValueString(isset($_POST['conditions']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString($_POST['drugs'], "text"),
GetSQLValueString($_POST['height'], "text"),
GetSQLValueString($_POST['weight'], "text"),
GetSQLValueString($_POST['race'], "text"),
GetSQLValueString(isset($_POST['retain-info']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString($_POST['comments'], "text"));
mysql_select_db($database_conn_db, $conn_db);
$Result1 = mysql_query($insertSQL, $conn_db) or die(mysql_error());
}
mysql_select_db($database_conn_db, $conn_db);
$query_Recordset1 = "SELECT * FROM study_applications";
$Recordset1 = mysql_query($query_Recordset1, $conn_db) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
对不起,这就是错误所说的
您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的“特定研究、推荐、生日、过夜、吸烟、脚本、过敏”附近使用正确的语法