> -----Original Message-----
> From: Brose, Eric [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 13, 2001 6:10 PM
> To: 'Bart Lateur'
> Cc: '[EMAIL PROTECTED] '
> Subject: RE: SQL statement.
>
>
> 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?

Because usually the id field for a table is numeric, at least in my
experience, but we took a guess.  In Oracle it doesn't matter most of the
time, since you can quote the numeric fields, but in Access you can't.


> DBI shouldn't really care how you pass it, does it?

Really, where did you get this fact?  This is totally db dependent, some
need it some don't.

Ilya


>
>
>
> -----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.
>

Reply via email to