MySQL Forums
Forum List  »  Perl

Unable to insert into table via perl cgi script...
Posted by: Mike Norris
Date: June 05, 2008 12:43PM

Hi peeps,

I'm having a problem with a perl cgi script running against mysql 5.0.51a-1.fc9. When attempting to insert data into a table no data is inserted and yet the unique id is being updated.

The relevant bits of code are;

sub update_page
my $pagename = shift;
my $timestamp = shift;
my $numofimages = shift;

my $query = "INSERT INTO photo_library.page_details(page_name, page_date, num_of_images) VALUES ('$pagename', '$timestamp', '$numofimages')";
my $query_handle = $photo_lib->prepare($query);
my $err = $query_handle->execute();

If I take the output of the printDebug statement and manually insert into the database the insert works fine as can be seen from the following where all three rows have been manually inserted but the ids have been updated from the cgi script insert attempts;

mysql> select * from page_details;
| id | page_name | page_date | num_of_images |
| 6 | test_page | 2008-06-03 | 0 |
| 15 | Page Three | 2008-06-05 | 0 |
| 17 | Page Four | 2008-06-05 | 0 |
3 rows in set (0.01 sec)

Running the following query from within the same cgi script gives the expected output so the database appears to working correctly;

sub query_page
my $p_name = shift;

my $query = "SELECT `page_name`, `num_of_images` FROM `photo_library`.`page_details` WHERE `page_name` = '$p_name'" ;
my $query_handle = $photo_lib->prepare($query);

my ($pageName, $imageCount);
$query_handle->bind_columns(undef, \$pageName, \$imageCount);


return ($pageName, $imageCount);

Hope someone can help with this as it is bugging me...


Options: ReplyQuote

Written By
Unable to insert into table via perl cgi script...
June 05, 2008 12:43PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.