What I would do....
Code:
$min=$ppp*$page; // FIND THIS TO BEGIN EDITS...
// write SQL queries as separate strings, so you can see what they actually are,
// not what you think they are
if($id){
$sqlquery1= "SELECT p.*,text$sfields,edited,tagval,u.id uid,name,$ufields,regdate FROM posts p,posts_text LEFT JOIN users u ON p.user=u.id WHERE thread=$id AND p.id=pid ORDER BY p.id LIMIT $min,$ppp";
$posts=mysql_query($sqlquery1);
if (False === $posts) {
echo "Error with \$id = $id <br/>";
echo mysql_error();
echo "<br/>SQL: $sqlquery1 " ;
}
} elseif($usr){
$thread[replies]=mysql_result(mysql_query("SELECT count(*) FROM posts WHERE user=$usr"),0,0)-1;
$sqlquery2 = "SELECT p.*,text$sfields,edited,tagval,u.id uid,name,$ufields,regdate FROM posts p,posts_text LEFT JOIN users u ON p.user=u.id WHERE user=$usr AND p.id=pid ORDER BY p.id LIMIT $min,$ppp" ;
$posts=mysql_query($sqlquery2);
if (False === $posts) {
echo "Error with \$usr = $usr <br/>";
echo mysql_error();
echo "<br/>SQL: $sqlquery2 " ;
}
}