Page 1 of 1

Help with PHP/Mysql codes

Posted: Fri Sep 05, 2003 10:35 pm
by Paulcren
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>

Posted: Sat Sep 06, 2003 6:13 am
by JAM
Change all ‘ and ’ to ' (single quotes) and try again.

Posted: Mon Sep 08, 2003 4:53 am
by twigletmac
Looks like the $_POST array may be empty - have you done:

Code: Select all

echo '<pre>';
print_r($_POST);
echo '</pre>';
to check what's in it?

Mac