Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Software error: DBD::mysql::st execute failed: Field 'name' doesn't have a default value

by jonnyfolk (Vicar)
on Oct 28, 2020 at 15:38 UTC ( #11123265=perlquestion: print w/replies, xml ) Need Help??

jonnyfolk has asked for the wisdom of the Perl Monks concerning the following question:

I was recently forced into a server change and it has broken an old script that's in use. I'm getting the error: "Software error: DBD::mysql::st execute failed: Field 'name' doesn't have a default value at admin.cgi line 192."

my $var; if ($new eq "charter") { $var = "c"; } elsif ($new eq "sales") { $va +r = "s"; } my $sth = $dbh->prepare("INSERT INTO $new (active) VALUES (0)"); #line 192 $sth->execute;

Could any kind Monk please advise on the steps I should take to troubleshoot this

NB. The script is connecting to the DB ok - other aspects like edit are working fine

  • Comment on Software error: DBD::mysql::st execute failed: Field 'name' doesn't have a default value
  • Download Code

Replies are listed 'Best First'.
Re: Software error: DBD::mysql::st execute failed: Field 'name' doesn't have a default value
by hippo (Chancellor) on Oct 28, 2020 at 16:17 UTC

    You are only specifying a value for field active not field name. The latter doesn't have a default value so the database rightly complains. Either specify a value for name in your SQL or alter the table definition in your DB to give name a default value.

    Note that this isn't a Perl problem. You would get the same response whatever DB client you used with the same query.


    🦛

      Thanks for your advice - much appreciated

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2020-12-04 12:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (58 votes). Check out past polls.

    Notices?