in reply to Re: Finding local vs Global Error
in thread Finding local vs Global Error

$sth2 = $dbh->prepare( 'insert into catalog values ($words, $index{$words})' );
Perl won't interpolate $words because it's inside single quotes. If $words is a string variable, even if it were interpolated, it wouldn't be proper SQL because string values need single quotes around them (in the SQL, not in the Perl). Easiest and best fix is placeholders:
$sth2 = $dbh->prepare('INSERT INTO catalog VALUES(?,?)'); $sth2->execute($words,$index{$words});

Replies are listed 'Best First'.
Re^3: Finding local vs Global Error
by Cappadonna3030 (Sexton) on Sep 21, 2005 at 01:15 UTC
    That worked, but I still get this error:
    Option type requires an argument DBD::mysql::st execute failed: You have an error in your SQL syntax ne +ar ' 0)' at line 2 at libbuilder.pl line 91. Issuing rollback() for database handle being DESTROY'd without explici +t disconnect().
    BTW, Here is the structure of my table in MYSQL:
    Database changed +----------+---------------------------------+------+-----+---------+- +------+ | Field | Type | Null | Key | Default | +Extra | +----------+---------------------------------+------+-----+---------+- +------+ | filename | varchar(60) | | PRI | | + | | filedir | varchar(80) | | | | + | | filetype | enum('article','email','other') | | | article | + | +----------+---------------------------------+------+-----+---------+- +------+ 3 rows in set (0.00 sec)
    Just wondering, since I'm using enum in MYSQL, can I represent my default variable as a 0? - Cappa