CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Why doesnt this line of code work??



May 24, 2007, 6:19 AM

Post #1 of 1 (794 views)
Why doesnt this line of code work?? Can't Post

Hi everyone. I'm currently trying to insert 2 values into a database but for some reason i keep getting errors.
Here is my code:

$cookie = $q->cookie('cart_id'); 
my @ListOfSongs = param("songs");

$sth = $dbh->prepare("INSERT INTO songs (cartID, song) VALUES (?,'?')") or die "Cannot prepare";

foreach $songs (@ListOfSongs) {
print "$songs\n";
$sth->execute($cookie, $songs) or die "Cannot execute";

The $cookie value holds an integer such as 4378349534
The $songs value holds a string such as Forest.mp3, Dont.mp3 etc.

The database schema is :

song CHAR(30));

I am getting an error on the execute line.

I have scoured the internet and cannot find why this would be a problem.

Cheers everyone


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives