问题
I'm successfully storing an IP address in my database using the the INET_NTOA function as follows:
$sql="INSERT INTO $tbl_subnets(address) VALUES(INET_NTOA('$address')
However when trying to reverse this when selecting the address using INET_ATON I get the the following error:
Fatal error: Call to undefined function INET_ATON()
Using this code...
<?php
$sql="SELECT * FROM subnets";
$result=mysql_query($sql);
// Start looping the rows in the database.
while($rows=mysql_fetch_array($result)){
?>
<td><?php echo $rows[INET_ATON('address')]; ?></td>
<?php
}
?>
Anyone can shed some light on this for me? Thanks
回答1:
inet_aton()
is a Mysql function. In PHP, you'd use inet_ntop() and inet_pton().
来源:https://stackoverflow.com/questions/8670221/fatal-error-call-to-undefined-function-inet-aton