The default behavior of the parameter binding encloses the
values in
single quotes. LIMIT requires two integers.
try this:
$sth->bind_param(1, $page, { TYPE => SQL_INTEGER });
$sth->bind_param(2, $results_per_page, { TYPE =>
SQL_INTEGER });
Otherwise, untaint the variables yourself and interpolate
them in the
string:
my ($clean_page,$clean_results_per_page) = map { s/D//g; }
($page,$results_per_page);
my $sth = $dbh->prepare("SELECT id,uname,maxdom FROM
tb_user order by
maxdom limit $clean_page, $clean_results_per_page");
On Thu, Feb 08, 2007 at 01:49:59PM +0530, Shyam S wrote:
> Hi,
>
> I have a problem, this is my code snippet
>
> my $sth = $dbh->prepare("SELECT
id,uname,maxdom FROM tb_user order by
> maxdom limit ? ,? ")
> or die "Couldn't prepare
> statement: " . $dbh->errstr;
>
> $sth->bind_param(1, $page);
> $sth->bind_param(2,
> $results_per_page);
> $sth->execute()
>
> the value of $page and $result_per_page is 4 and 2
respectivey
>
> but is showing some error,
>
> Check the manual that corresponds to your MySQL
server version for the
> right
> syntax to use near ''4' ,'2'' at line 1 at
listuser.pm line ...
>
> I think 4 and 2 is taken as some character.if I give
4 and 2 directly in
> sql that will work fine. Could any body help me in
fixing it.
>
> Regards
> Shyam
>
> [Non-text portions of this message have been
removed]
>
>
--
Brad Lhotsky
Unsubscribing info is here: h
ttp://help.yahoo.com/help/us/groups/groups-32.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://g
roups.yahoo.com/group/perl-beginner/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http
://groups.yahoo.com/group/perl-beginner/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:perl-beginner-digest@yahoogroups.com
mailto:perl-beginner-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
perl-beginner-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.c
om/info/terms/
|