SQL Syntax in DBD::mysql

------=_NextPart_000_000D_01C263B6.FA136D10
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I am trying to use the following code to insert data into a mysql =
database:-


# write the information to the database
$sth=3D$dbh->prepare("INSERT INTO =
images(name,desc,category,subcat1,subcat2,image) VALUES(?,?,?,?,?,?)");

$sth->bind_param(1,$name);
$sth->bind_param(2,$desc);
$sth->bind_param(3,$category);
$sth->bind_param(4,$subcat1);
$sth->bind_param(5,$subcat2);
$sth->bind_param(6,$photo);

$sth->execute;


I get syntax error in sql statement. The image field is a blob so I'm =
not sure if a string is the correct format but from the manual it =
appears that DBI only understands string or number formats. The photo =
variable holds the binary data.

The format above as far as I can tell conforms to the standard DBI =
format but the DBD::mysql man page is not particularly explicit in this =
area.

Thanks.

Jon.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.385 / Virus Database: 217 - Release Date: 04/09/2002

------=_NextPart_000_000D_01C263B6.FA136D10--

0
samur2
9/24/2002 9:41:45 AM
perl.dbi.users 11080 articles. 1 followers. Follow

1 Replies
254 Views

Similar Articles

[PageSpeed] 6

At 10:41 +0100 9/24/02, Jon Wyatt wrote:
>I am trying to use the following code to insert data into a mysql database:-
>
>
># write the information to the database
>$sth=$dbh->prepare("INSERT INTO 
>images(name,desc,category,subcat1,subcat2,image) 
>VALUES(?,?,?,?,?,?)");
>
>$sth->bind_param(1,$name);
>$sth->bind_param(2,$desc);
>$sth->bind_param(3,$category);
>$sth->bind_param(4,$subcat1);
>$sth->bind_param(5,$subcat2);
>$sth->bind_param(6,$photo);
>
>$sth->execute;
>
>
>I get syntax error in sql statement.

"DESC" is a keyword.

>  The image field is a blob so I'm not sure if a string is the 
>correct format but from the manual it appears that DBI only 
>understands string or number formats. The photo variable holds the 
>binary data.
>
>The format above as far as I can tell conforms to the standard DBI 
>format but the DBD::mysql man page is not particularly explicit in 
>this area.
>
>Thanks.
>
>Jon.

0
paul
9/24/2002 1:21:47 PM
Reply: