xyn Posted November 27, 2007 Share Posted November 27, 2007 Hey guys. I've been using pagination alot. However recently i've decided to create a class. The class contains a function to collect the items from a database. Everything works fine until i use LIMIT $x,$y. kinda thing. then i get the following error 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 '' at line 11. My php page is. (this is the snipper which is needed.) $cpage =(!$_GET[p])? 1:$_GET[p]; $template_nav = $template->assign_navigation($cutom_folders); $page_info.= $template->pm_reminder($estarray); $page_info.= $messenger->inbox; $page.= $messenger->collect_items($cpage,$messenger->pmpagelimit); if($messenger->inbox_items()){ #while($item = $messenger->collect_items()){ # $page.= "test"; #} } $page.= "inbox"; this is my class function.. function collect_items($page,$limit){ $sql = mysql_query("select `pmid`, `pmauthor`, `pmsubject`, `pmsubmitted`, `pmstatus`, case when `pmstatus`='0' then 1 when `pmstatus`='1' then 2 else 3 end as `pmsort` from `".$this->tbl."messenger` where `pmrecipient`='".$_SESSION[$this->session]."' and `pmdeleted`='0' and `pmfolderid`='0' order by `pmsort`,`pmsubmitted` desc limit $page,$tlimit") or trigger_error(mysql_error(),E_USER_ERROR); return mysql_fetch_array($sql); } However if i use this. the error will no show-up. function collect_items($page,$limit){ $sql = mysql_query("select `pmid`, `pmauthor`, `pmsubject`, `pmsubmitted`, `pmstatus`, case when `pmstatus`='0' then 1 when `pmstatus`='1' then 2 else 3 end as `pmsort` from `".$this->tbl."messenger` where `pmrecipient`='".$_SESSION[$this->session]."' and `pmdeleted`='0' and `pmfolderid`='0' order by `pmsort`,`pmsubmitted` desc") or trigger_error(mysql_error(),E_USER_ERROR); return mysql_fetch_array($sql); } Quote Link to comment https://forums.phpfreaks.com/topic/79127-solved-unknown-mysql-limit-problem/ Share on other sites More sharing options...
xyn Posted November 27, 2007 Author Share Posted November 27, 2007 I managed a fix. but i'm not sure how i did it :l. Quote Link to comment https://forums.phpfreaks.com/topic/79127-solved-unknown-mysql-limit-problem/#findComment-400505 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.