On Mon, 29 Sep 2003 22:35:10 -0700 (PDT) [EMAIL PROTECTED] wrote:

> Can someone explain why passing the parameter behave like it did or
> atleast explain the best way to pass parameters here?
> 
> $dbh = DBI->connect('dbi:mysql:userdb','user', 'pw');
> $sth=$dbh->prepare("SELECT * FROM myusers where username = ?");
> 
> #this works
> $sth->execute(bob) || die "SQL error: $!\n";
> 
> #this did NOT work with double quotes why?
> $sth->execute("bob") || die "SQL error: $!\n";

You can find out what happened if you use $DBI::errstr instead of $!.
If that isn't enough, add $dbh->trace(2) before the execute() calls.

The two statements should have the same effect, but it's dangerous to
depend on Perl to treat the unquoted bob as a string literal.

-- 
Mac :})
** I usually forward private questions to the appropriate mail list. **
Ask Smarter: http://www.catb.org/~esr/faqs/smart-questions.html
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.

Reply via email to