Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Insert into mysql database

by hippo (Chancellor)
on Mar 02, 2021 at 22:58 UTC ( #11129037=note: print w/replies, xml ) Need Help??


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 (Cardinal) 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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11129037]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2021-04-13 03:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?