in reply to Re^4: Perl and Mysql Queries
in thread Perl and Mysql Queries

I haven't a clue as to what the 'Can't call method "prepare' error means by 'undefined value'.

It's telling you that you have done effectively this:

$ perl -E '$x->prepare("foo");' Can't call method "prepare" on an undefined value at -e line 1.

Your connection statement failed and therefore you don't have a defined database handle. So when you try to call the prepare method you are doing it on something which is undefined as $x is in the snippet above.

All of this is because the connection failed. Fix the first problem first, as always.

Which version of DBD::mysql are you running?


🦛

Replies are listed 'Best First'.
Re^6: Perl and Mysql Queries
by Milti (Beadle) on Jun 11, 2024 at 15:08 UTC
       Undefined subroutine &main::param called

      That means CGI::param wasn't imported into main::param. It looks for main::param but can't find it. Make sure you import CGI::param with 'use CGI qw/:standard/;' or however you want. You might also consider using the object oriented style like.

      use CGI: my $q = CGI->new; my $var = $q->param('param_key');
      <error message Tue Jun 11 08:41:15 2024 error client 73.21.226.229 Undefined subroutine &main::param called at E:\\Pinnacle\\DiversityLink\\cgi-bin\\job_post_test.pl line 13.,

      <Per a previous answer it appears that the following 'connect' statement has an error

      my $dbh = DBI->connect('dbi:mysql:jobs_db','Poster','Posterpasswd');

      What could it be when GRANT ALL have been given to the user 'Poster' Identified by 'Posterpasswd' ?