1

I have been working on this problem for some time now and I don't seem to understand even after referencing other previously asked questions what I am doing wrong.

Working Solution:

  $stmt = $dbh->prepare("SELECT * FROM tempTable ORDER BY id ASC LIMIT 1 , 7");

Non-Working Solution:

  $limit1 = 1;
  $limit2 = 7;
  $stmt = $dbh->prepare("SELECT * FROM tempTable ORDER BY id ASC LIMIT :start , :end");
  $stmt->execute(array(':start' => $limit1, ':end' => $limit2));

I have never had an issue with pdo / sql using php before like this and apparently have no understanding of why this is occurring.

Thanks for the help!

Bryce
  • 447
  • 2
  • 9
  • 24

1 Answers1

1

i was really having the same issue until i bind then try this piece of code

  $limit1 = 1;
  $limit2 = 7;
  $stmt = $dbh->prepare("SELECT * FROM tempTable ORDER BY id ASC LIMIT :start , :end");
  $stmt->bindParam(':start',$limit1);
  $stmt->bindParam(':end',$limit2);
  $stmt->execute();

it should work with it

PacMan
  • 1,358
  • 2
  • 12
  • 25