Possible Duplicate:
PHP PDO bindValue in LIMIT
I could not display the data when using LIMIT and/or OFFSET in the prepare statement, but I can show "Lei Lei" if I don't use the LIMIT and OFFSET, does the code look wrong?
$statement = $conn->prepare("SELECT id,username FROM public2 WHERE username = :name LIMIT :sta OFFSET :ppage");
$name = "Lei Lei";
$statement->execute(array(':name' => $name,':sta' => $start,':ppage' => $per_page));
This have been change from the original code which worked:
$query_pag_data = "SELECT id,username from public2 LIMIT $start, $per_page";
$result_pag_data = mysql_query($query_pag_data) or die('MySql Error' . mysql_error());
I found the answer!
$statement->bindValue(':sta1', (int) $start, PDO::PARAM_INT);
does work
$dbh->setAttribute( PDO::ATTR_EMULATE_PREPARES, false );
will let you bind variables without being bothered of them type
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With