error in SQL syntax
Posted: Sat Apr 17, 2004 11:55 pm
Hi, i'm doing this project from a tutorial to learn php and I can't find the problem with this function, MySQL give me the error:
heres the code:
if you need any more information i'll be glad to give it.
can anyone help?getEvents fatal 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 'clubs, events, areas, types WHERE clubs.id=events.eclub AN
heres the code:
Code: Select all
function getEvents($club_id=0, $range=0, $area=0, $type=0)
{
global $link;
$query="SELECT clubs.name, events.*, areas.area as areaname,
types.type as typename";
$query .="FROM clubs, events, areas, types WHERE ";
$query .="clubs.id=events.eclub
AND events.area=areas.id
AND events.type=types.id";
if( ! empty($club_id) && $club_id !="ANY")
{
$query .="AND events.eclub='$club_id'";
}
if( ! empty($range))
{
$query .="AND events.edate >='$rangeї0]' AND
events.edate<='$rangeї1]'";
}
if(! empty($area) && $area !="ANY")
{
$query .="AND events.area='$area'";
}
if( ! empty($type) && $type !="ANY")
{
$query .="AND events.type='$type'";
}
$query .="ORDER BY events.edate";
$result=mysql_query($query, $link);
if( ! $result)
{
die("getEvents fatal error: ".mysql_error());
}
$ret=array();
while($row=mysql_fetch_array($result))
{
array_push($ret, $row);
}
return $ret;
}