Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't call method "execute" on an undefined value at... 1

Status
Not open for further replies.

SCelia

Programmer
Feb 27, 2002
82
CA
That error is beginning to get on my nerves. I just can't figure out what I messed up. Hoping you folks will be able to tell me.

statement:

$table = 'tourney';

my $sth = $dbh->prepare("INSERT INTO $table VALUES (?,?,?,?,?,?)") or die "Couldn't prepare statement: " . $dbh->errstr;

execute:

$sth->execute($rank, $name, $land, $nw, $game, $set) or die "Couldn't execute statement: " . $sth->errstr;

Niether one dies with errors but when it tries to execute the statement the program stops execution and I see "Can't call method "execute" on an undefined value at..." in my error log.

Any ideas?

Thanks,
Celia
 
I have the same kind of error too but it just happen during morning.
Error:
Software error:
Can't call method "execute" on an undefined value at ......

Does anybody know why?
 
I have no clue myself. I just spent less time converting the whole shebang to php and getting it working than I wasted trying to get it working with perl. Celia
 
I just had this problem and after searching all over the net with no one having a clue i fixed it by messing around. I used odbc in windows to connect but i used the user dns to set it up, i changed it to system dns and it works. hope it works for everyone else too.

ps dont have the user dns set up at all, doesn't like that.just the system one.

good luck
Mark
 
Have you run, and passed, the installation tests for DBD::MySql? Mike
________________________________________________________________

"Experience is the comb that Nature gives us, after we are bald."

Is that a haiku?
I never could get the hang
of writing those things.
 
Hi SCelia,

It might be the info the user is placeing in the html form. For example, one of my forms call for the user to enter a Business Name. If the user entered "Peg's Ebay Antiques" and the form's submit passed that to the perl script, that in turn tries to insert it into the MySQL database, the insert will fail with no error message. You see, MySQL cannot handle an apostrophe unless it is escaped, and most user do not know how to escape their input into an html form. I have perl code that trap for apostrophes to prevent this kind of problem.

If you place the print html/text statement right before trying to do the insert, you can print out each of the variable to the screen. In this way you can see whether what the user entered into the form is captured correctly by the perl script an inserted into the MySQL table.

Here is an example I use in one of my scripts:


print "Content-type: text/html\n\n";

print &quot;CNO: $count<BR>&quot;;
print &quot;First Name: $lfirst<BR>&quot;;
print &quot;Last Name: $llast<BR>&quot;;
print &quot;Date: $ldate_it<BR>&quot;;
print &quot;Company Name: $lcompany<BR>&quot;;
print &quot;Address 1: $laddress<BR>&quot;;
print &quot;City: $lcity<BR>&quot;;
print &quot;State: $lstate<BR>&quot;;
print &quot;Postal: $lpostal<BR>&quot;;
print &quot;Phone: $lphone<BR>&quot;;
print &quot;Email: $lemail<BR>&quot;;
print &quot;Key number: $lpass_key<BR>&quot;;
print &quot;Pay By: $lpayby<BR>&quot;;
print &quot;Card Type: $lcardtype<BR>&quot;;
print &quot;Card Holder Name: $lcardholder<BR>&quot;;
print &quot;Card Number: $lcardnumber<BR>&quot;;
print &quot;Month $lcardmonth<BR>&quot;;
print &quot;Year $lcardyear<BR>&quot;;
print &quot;Amount: $lamount<BR>&quot;;
print &quot;Processed: $lprocessed<BR>&quot;;

Leland F. Jackson, CPA
Software - Master (TM)
Nothing Runs Like the Fox
 
Hi,

Im very new to perl (about 2 dayz). I had a similar problem, it was my connect() here is the working version.. of course all the variables are specified.. ill leave them out for rooms sake.

my $dbh = DBI->connect(&quot;DBI:mysql:database=$serverDb;host=$serverName;port=$serverPort&quot;, $serverUser, $serverPass);

as specified here :
This works for me, with the some tooling around with the GRANT tables for $serverDB.

I see there is alot of variance in syntax that is posted here, and I hate to go off topic but is this something related to version, or is perl really that liberal with syntax slips w/o strict ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top