SELECT sorgusu MySQL sözdizimi hatası

0 Cevap php

Merhaba herkes

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.

Bu kodu:

$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';
}

Bu hatayı döndürür:

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 all returns a value.

0 Cevap