I know I'm probably missing something obvious here but...
How do I alter/insert a null value in a database from Perl?
No matter how I do it it always ends up being wrong.
What I've tried to do is the following:
my $sth=$dbh->prepare("insert into customer (id,name,lastname,email) values
(null,?,?,?);");
$sth->bind_param(1,$name);
$sth->bind_param(2,$lastname);
$sth->bind_param(3,$email);
$sth->execute();
$dbh->disconnect();
The variables I get from a webpage, so what I'm trying to accomplish is a
cgi-script to add
things to a database. Works just fine except that null thing. Oh, and ID is
an auto-increment
field so that's not a problem.
The email-field is supposedly meant to be null if nothing's entered there
but no matter what I'm doing
I get an empty string added into that particular field instead, which isn't
at at all what I'm after.
So, how do I do substitute the empty string with a null value before
committing the execute() call?
Any ideas?
/Jonas