|more useful options|
Using placeholders in MySQL returning an errorby bradcathey (Prior)
|on Jan 16, 2004 at 16:07 UTC||Need Help??|
bradcathey has asked for the wisdom of the Perl Monks concerning the following question:
Fellow monasterians, I have successfully used placeholders in previous projects, but running into a problem with this one. Getting the Can't call method 'prepare' on an undefined value at... error. In checking with the DBI docs on CPAN I see nothing unusual.
My guess is that the fields in my database are not matching up with the placeholders. My fields are named exactly as the scalars you see in the code, and the empty values you see at the beginning and end of the list in the 'execute' statement are for the auto-incremented id and a TIMESTAMP.
However, no matter how I adjust the number of ? marks or execute values, I get the error (in the code below their are 17 ?'s and 17 values). A recent node by grinder that mentions the placeholder for an auto incre. id is not necessary (however, I have found in other scripts this was necessary--weird). What about the TIMESTAMP? Does it need a placeholder? Anyway, here's the suspect code. Thanks!
Something injunjoel said caused me to go back and discover my problem was coming before the prepare and execute statements. I learned a valuable lesson. But I also learned a lot about placeholders, and I'm indebted again to the monastery for wise replies. Problem solved and code improved. Thanks. Also, fixed references from injunjoe to injunjoel (I need new glasses).
"A little yeast leavens the whole dough."