錯誤接收:PHP的錯誤,錯誤SQL語法中
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 'Group, Event) VALUES (
當我點擊register.php文件中註冊。幫幫我!
Register.php
<form id='register' action='RegisterCode.php' method='post' accept-charset='UTF-8'> <table>
<tr> <td> Name: </td> <td> <input type="text" name="Name" maxlength="50" /> </td> </tr>
<tr> <td> Age: </td> <td> <input type="text" name="Age" maxlength="2" /> </td> </tr>
<tr> <td> Contact: </td> <td> <input type="text" name="Contact" maxlength="8" /> </td> </tr>
<tr> <td> Email: </td> <td> <input type="text" name="Email" maxlength="200" /> </td> </tr>
<tr> <td> Gender: </td> <td> <input type="text" name="Gender" maxlength="2" /> </td> </tr> <tr> <td> Address: </td><td> <input type="text" name="Address" maxlength="100"/></td></tr>
<tr> <td> Which Industry/ Occupational Group: </td> <td>
<select name="Group"> <option value="Student">Student</option> <option value="Employed">Employed</option> <option value="Unemployed">Unemployed</option> <option value="Retired">Retired</option>
</select>
<tr> <td> How did you know about this event: </td> <td>
<select name="Event"> <option value="Online">Online</option> <option value="Newspaper">Newspaper</option> <option value="Friend">Friend</option> </select>
<tr><td></td><td><input class="formstylethree" type="submit"></td></tr> </table></form>
RegisterCode.php
<?php require_once("includes/connection.php");?> <?php require_once("includes/functions.php"); ?> <?php $sql="INSERT INTO registration(Name, Age, Contact, Email, Gender, Address, Group, Event) VALUES ('$_POST[Name]','$_POST[Age]','$_POST[Contact]','$_POST[Email]','$_POST[Gender]','$_POST[Address]','$_POST[Group]','$_POST[Event]')";
if (!mysql_query($sql,$connection)) { die('Error: ' . mysql_error()); } else { $location="index.php"; header("Location: {$location}"); echo "1 record added" . $sql; }
mysql_close($connection); ?>
登記表
Name varchar (50)
Age int(2)
Contact varchar(8)
Email varchar(200)
Gender varchar(200)
Address varchar(200)
Group varchar(150)
Event varchar(150)
+1最快的手指! –