PDO分页语法违规错误

时间:2017-01-01 13:26:39

标签: php mysql pdo paging

有人可以查看下面我的脚本是否有错误。

我收到“PHP致命错误:未捕获异常'PDOException'消息'SQLSTATE [42000]:语法错误或访问冲突:1064您的SQL语法出错;请查看与您的MySQL服务器对应的手册正确语法的版本在“0”附近使用,“1”在第1行“

    $limit = 1;
$p=$_GET['p']=="" ? 1:$_GET['p'];

$start=($p-1)*$limit;


$sa_stmt = $db->prepare('SELECT * FROM members WHERE referral=:username ORDER BY memberID LIMIT :start, :limit');


$sa_stmt->execute(array(
                ':username' => $_SESSION['username'],
                ':start' => $start,
                ':limit' => $limit
            ));

while($info = $sa_stmt->fetch(PDO::FETCH_ASSOC)){ 
 $norec = "yes";
echo ''.$info["username"] . '    '; }


$count=$db->prepare("SELECT COUNT(memberID) FROM members WHERE referral=:username ORDER BY memberID");
$count->execute(array(':username' => $_SESSION['username']));
$count=$count->fetchColumn();

$countP=(ceil($count/$limit)) + 1;
$tW=($countP*50) + $countP;
echo"<center style='overflow-x:auto;margin-top:10px;padding-bottom:10px;'>";
 echo"<div style='width:".$tW."px'>";
 for($i=1;$i<$countP;$i++){
  $isC=$i==$_GET['p'] ? "b-green":"";
  echo "<a href='?p=$i'><button class='pgbutton $isC'>$i</button></a>";
 }
 echo"</div>";
echo"</center>";

1 个答案:

答案 0 :(得分:1)

linked_device