Bart,
Why do your assume that the $ID_code is numeric?
Is the dB complaining because the variable isn't being passed as a numeric?
DBI shouldn't really care how you pass it, does it?
-----Original Message-----
From: Bart Lateur [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 13, 2001 3:05 PM
To: [EMAIL PROTECTED]
Subject: Re: SQL statement.
On Thu, 14 Jun 2001 04:07:14 +0700, Krung Saengpole wrote:
>$sql = "Select * From myTable Where ID_Code = ?";
>$sth = $dbh->prepare($sql);
>...
>$sth->execute($ID_code); #ID_code contains ID_Code value
>I have to change $sql to "Select * From myTable Where ID_Code=$ID_code" and
call $sth->execute() instead to fetch the result to $rc. What's wrong with
my code?
I don't see anywhere that you tell the db that your placeholder is
numeric. Under the prepare statement, do:
$sth->bind_param(1, undef, SQL_INTEGER);
You need to have these constants, by loading DBI as such:
use DBI ':sql_types';
Also, have you set PrintError and/or RaiseError to true? That would help
in debugging.
--
Bart.