Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Mysql syntax error

by batkins (Chaplain)
on Nov 10, 2003 at 18:18 UTC ( [id://305927]=note: print w/replies, xml ) Need Help??


in reply to Mysql syntax error from DBI

Since "drain cleaner" is two words, it should be quoted. An easy way to solve this and similar problems is to use placeholders. Something like:
my $sth =$dbh ->prepare("UPDATE products set pname=? and unit=? and q +ty=? and cost=? WHERE id = ?"); $sth->execute($pname, $unit, $qty, $cost, $id);
should do the trick. The question marks are replaced by the values passed to execute. For more information, see DBI.

Are you sure it was a book? Are you sure it wasn't.....nothing?

Replies are listed 'Best First'.
Re: Re: Mysql syntax error
by dbwiz (Curate) on Nov 10, 2003 at 19:00 UTC
    my $sth =$dbh ->prepare("UPDATE products set pname=? and unit=? and qty=? and cost=? WHERE id = ?");
    should do the trick.

    No. It shouldn't.

    The SQL syntax is wrong (see meetraz's answer.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://305927]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2024-04-16 12:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found