开发者

how to ensure a null value is not being input into a mysql database row?

Here is my situation. From a previous question I was given the answer to get value from grep method.

  while(<READFILE>)
  {
       my ($dbtest_name) = grep(/@/,@dataRecord); 

       // Next I insert this value into a mysql database I get the following error message.

       $sth->execute($dbtest_name);
  }    
      DBD::mysql::st execute failed: 开发者_如何学运维Column 'test' cannot be null 
      Use of uninitialized value $dbtest_name in print

Question, how can I ensure a value from $dbtest_name variable always have a value and not null?


Using the defined function:

next unless defined $dbtest_name;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜