This is PerlMonks "Mobile"

Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  


in reply to Insert into mysql database

Is this old Perl and not compatible with the newer version of MYSQL?

It's a style of Perl that is not often seen anymore, but that doesn't mean that it won't actually run - even with a modern target database. The problem is that your error message is going to be 'Could not execute SQL statement ... maybe invalid?' regardless of what the actual underlying cause is. That's no use for debugging. Consider something like this instead:

$sth->execute(@bargs) or die "Could not execute '$query' with argument +s '@bargs': " . $dbh->errstr;

That would give you already a lot more information about the problem. I've also passed an array of bind arguments @bargs to the execute call. This means using placeholders which is far, far safer than the prepare statement that you have. Definitely something else to look into.

The new server runs a newer version of PHP (version 7.X)

I do hope that's irrelevant. You aren't actually using the PHP for anything, are you?


🦛

Replies are listed 'Best First'.
Re^2: Insert into mysql database
by LanX (Saint) on Mar 02, 2021 at 23:26 UTC
    > This means using placeholders which is far, far safer than the prepare statement that you have

    Kind of an understatement, Little Bobby Tables would really love this particular entry $form{'ITEM'} ...

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery