Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7171127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:21:04+00:00 2026-05-28T15:21:04+00:00

I am having the following problem: Environment PHP, codeigniter framework with PDO. my code

  • 0

I am having the following problem:

Environment PHP, codeigniter framework with PDO.

my code

public function index(){

        $sql = "SELECT ........ LIMIT ?,?";

        $q = $this->db->prepare($sql);

        $limit = 0;

        $offset = 10;

        $q->execute(array($limit, $offset));           

        $r = $q->fetch();

        var_dump($r);

    }

problem: There is no problem in the sql query as, if i hardcode any integers (e.g. 0, 10) in the LIMIT clause; the query returns the desirable result. The problem occurs only when binding the params.

Error shown dumping the $r in above code returns bool(false)

Now, the following code runs successfully,

public function index(){

        $sql = "SELECT ........ LIMIT 0,10";

        $q = $this->db->prepare($sql);           

        $q->execute();           

        $r = $q->fetch();

        var_dump($r);

    }

what can be the problem in the former code while binding? Am i doing it wrongly or could there be chance that it is creeping up due to codeigniter not supporting PDO by default?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T15:21:06+00:00Added an answer on May 28, 2026 at 3:21 pm

    As adviced, I am putting my own answer.

    You can’t bind variables to LIMIT or ORDER by clause

    SOLUTION:

    Pass it as a variable in the sql query (And probably sanitize with intval just to be safer.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having the following problem: Warning: include_once() [function.include]: Failed opening 'Mail_Mime/mime.php' for inclusion
I'm having following problem. I should convert a control to a certain type, this
I'm having the following problem. I created a application context file for spring.net. The
I'm having the following problem and wondered whether anyone could see why this is
I have been having the following problem, i think it's probably due to the
I'm having the following problem using the Visual Studio 2010 Team System Beta 1:
I've been having the following problem with my GoDaddy's server. I am using JSPs
I'm having the following problem: When I got two labels into each other: <Label
I'm using Qt Creator 4.5 with GCC 4.3 and I'm having the following problem
I'm having some difficulties with the following problem: I'm making a little game where

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.