Hi,
I'm trying to create Member.php script to be used in my member registration form. But, I getting mysql error message:
Error in query: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 ' '' , '' , '', ‘, ‘, ‘, ‘, ‘, ‘, ‘, ‘, ‘, ‘, ‘, ‘, ‘)' at line.
Could someone please check the codes below and give me suggestions on what to do to fix this error.
Thanks in advance.
<?php
$Graduation_Year=$_POST['Graduation_Year'];
$Surname=$_POST['Surname'];
$Given_name=$_POST['Given_name'];
$School_Attended=$_POST['School_Attended'];
$City=$_POST['City'];
$Fellowship_Attended=$_POST['Fellowship_Attended'];
$Gender=$_POST['Gender'];
$Title=$_POST['Title'];
$Current_Surname=$_POST['Currentl_Surname'];
$Current_Name=$_POST['Current_Name'];
$Email=$_POST['Email'];
$Confirm_email=$_POST['Confirm_Email'];
$Current_Country=$_POST['Current_Country'];
$Current_State=$_POST['Current_State'];
$Current_City=$_POST['Current_City'];
$Occupation=$_POST[‘Occupation’];
$Church_Membership=$_POST[‘Church_Membership’];
//////////////////////////////////////// CONNECT TO MYSQL DB ////////////////////
// OPEN CONNECTION --->
$connection=mysql_connect ("localhost", "", "") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("");
$query="INSERT INTO Member ( Graduation_year, Surname, Given_name, School_Attended, City, Fellowship_Attended, Gender, Title, Current_Surname, Current_Name, Email, Confirm_email, Current_Country, Current_State, Current_City, Occupation, Church_Membership)
VALUES(‘$Graduation_Year’, '$Surname' , '$Given_Name' ,
'$School_Attended', ‘$City’, ‘$Fellowship_Attended’, ‘$Gender’, ‘$Title’, ‘$Current_Surname’, ‘$Current_Name’, ‘$Email’, ‘$Confirm_Email’, ‘$Current_Country’, ‘$Current_State’, ‘$Current_City’, ‘$Occupation’, ‘$Church_Membership’)";
$result=mysql_query($query) or die("Error in query:".mysql_error());
mysql_close($connection);
?>
</body>
</html>
Help with PHP/Mysql codes
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Looks like the $_POST array may be empty - have you done:
to check what's in it?
Mac
Code: Select all
echo '<pre>';
print_r($_POST);
echo '</pre>';Mac