Hi everyone i'm getting this syntax problem and i don't see anything wrong with my query. I'm kind of new at SQL as i'm still an undergrad. I'd really appreciate it if you could help me with this. This is the code. :
$results = mysql_query("SELECT event.nameevent,event.eventid
FROM event,sub
WHERE sub.userid=$userid AND event.eventid=sub.orgid AND
EXTRACT(YEAR FROM startdate)=$year AND EXTRACT(MONTH FROM startdate)=$month
AND EXTRACT(DAY FROM startdate)=$list_day")
or die(mysql_error());
if(mysql_num_rows($results) >0 )
{
while($row=mysql_fetch_assoc($results))
{
$nameevent = $row['nameevent'];
$eventid = $row['eventid'];
$calendar.="<a href='memberview.php?eventid=$eventid'>".$nameevent."</a>";
$calendar.= "<br>";
}
}
else
{
$calendar.='you have no events today';
}
It returns this 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 'AND event.eventid=sub.orgid AND EXTRACT(YEAR FROM startdate)=2010 AND EXTRACT( at line 3
I tested this code in a blank page and it works however when i integrate it inside the calendar page it doesn't work. Any suggestions? I have tested $userid,$year,$month and $day and it all returns a value.