Jump to content

[SOLVED] Unknown mysql Limit problem.


xyn

Recommended Posts

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);
}

Link to comment
https://forums.phpfreaks.com/topic/79127-solved-unknown-mysql-limit-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.