Jeff Snoxell wrote:
> Hello,
>
> I've got a mysql table with a lot of fields and I'm using a map statement
> to pass each of my values for a new record through the quote system so-as
> to have everything nicely wrapped up. Problem is that I can't find any way
> of writing a null value to my DB when the value has first passed through
> quote().
>
> I've tried:
>
> my $err = $MyDatabase->do('INSERT INTO MyTable VALUES(' .
> join(",",map($MyDatabase->quote($_),
> 0, # REF
> 0, # PARENT REF
> $FormData{'Title'} . " " . $FormData{'Name'} . "",
> $FormData{'Email'} . "",
> "\N", # <-- I REALLY WANT THIS TO BE A NULL VALUE!
> etc.,
> etc.,
> etc.....
> )) .
> ')');
>
> Which works fine except the "\N" isn't entered into my database as a null
> value. I've also tried '\N' and '' and "".
>
> Any ideas how I can solve this easily?
>
> Thanks,
>
> Jeff
>
> ---------------------------------------------------------------------
> Before posting, please check:
> http://www.mysql.com/manual.php (the manual)
> http://lists.mysql.com/ (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Jeff,
I'm not sure if this will help or not, but we ended up adding our own version of
quote to
perl cgis. Someone told me when I ask a similar question to check the value
before calling
quote, but it seemed like more of a headache... You may have to use perl's ord &
chr to look for
\n
walt
sub nea_quote
{
my ($input) = @_;
if (length($input) == 0)
{
$return_string = "NULL";
return $return_string;
}
else
{
$return_string = $dbh->quote($input);
return $return_string;
}
}
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php