Hello,
I'm new to the forums. And a beginner to PHP.
I have been creating a members only website for my youth club .One of the features is being able to sign up for events through the website. I am having trouble with the script that adds the person to that event's mysql table.
Error message:
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 '1 WHERE name='JLisle'' at line 1
Here is the script below:
<?php
if(!isset ($_COOKIE["CASPA"]))
{
header("Location: ../../output/members/loginpage.php?id=1");
}
else
{
$con=mysql_connect("localhost","user","pass");
mysql_select_db("james232_Events");
$id=$GET["id"]; //The ID is the ID of the event which is also the name of the table
$user=$COOKIE["CASPA"];
$check="SELECT * FROM $id WHERE name='$user'";
$checkq=mysql_query($check) or die(mysql_error()); //Query that doesn't function
$result=mysql_num_rows($checkq);
if($result==0)
{
mysql_select_db("james232_Members");
$sqlid="SELECT id FROM members WHERE username='$user'";
$idq=mysql_query($sqlid);
$idl=mysql_result($idq,0);
$sqle="SELECT email FROM members WHERE username='$user'";
$ide=mysql_query($sqlid);
$e=mysql_result($idq,0);
mysql_select_db("james232_Events");
$insert="INSERT INTO $id (memberID,name,email) VALUES ('$idl','$user','$e')";
mysql_query($insert);
mysql_close($con);
header("Location: ../../output/members/events.php?id=1");
}
else
{
mysql_close($con);
header("Location: ../../output/members/events.php?id=2");
}
}
?>