Leser: 15
1 2 3
my $sth = $dbh->do("INSERT INTO `accounting` (`IPv6_string`, `IPv6_binary`) VALUES ('fd01:0000:0000:0000:0000:0000:0000:0003', 0xfd010000000000000000000000000003);");
1 2 3 4 5
my $sth = $dbh->prepare("INSERT INTO `accounting` (`IPv6_string`, `IPv6_binary`) VALUES (?, ?);"); $sth->bind_param(1, 'fd01:0000:0000:0000:0000:0000:0000:0003'); $sth->bind_param(2, '0xfd010000000000000000000000000003', SQL_VARBINARY); $sth->execute();
QuoteHier ist es einfach ein String, der zufällig mit "0x" anfängt und keine Hex-Zahl mehr. Lass mal die ' ' weg.Code: (dl )$sth->bind_param(2, '0xfd010000000000000000000000000003', SQL_VARBINARY);
1 2 3 4 5 6 7
my $ip_hex = 'fd010000000000000000000000000003'; my $ip_ascii = unpack("A16", pack("H32", $ip_hex)); my $sth = $dbh->prepare("INSERT INTO `accounting` (`IPv6_string`, `IPv6_binary`) VALUES (?, ?);"); my @values = ('fd01:0000:0000:0000:0000:0000:0000:0003', $ip_ascii); $sth->execute(@values);