in reply to Using SQL Placeholders correctly

$sth_m->execute('?', '$year-$mon-$mday', '$INPUT{'user'}', 'INPUT{'ref'}', '$INPUT{'username'}', 'notread', '$memo_final')

You will want to use double quotes around anything that contains variables, and lose any quotes around the simple scalar values, you don't need any quotes there!

$sth_m->execute('?', "$year-$mon-$mday", $INPUT{'user'}, $INPUT{'ref'} +, $INPUT{'username'}, 'notread', $memo_final);

Liz

Replies are listed 'Best First'.
Re: Re: Using SQL Placeholders correctly
by pg (Canon) on Dec 21, 2003 at 23:29 UTC

    What does that first '?' mark mean? It makes no sense unless you are setting the value of id to '?'.

    ? as placeholder is only meaningful when you prepare the statement, not at the time you execute it. I think you missed the true meaning of placeholder.

    For auto-increment field, you don't set value for it, otherwise what does that'auto-' mean? just take that field out from the insert statement, and database will fill in the right value for you.