I have ip_addresses that were imported as strings into the database and stored as unsigned integers. I want to display them in standard xxx.xxx.xxx.xxx format in a table. In my code, I tried the following:
<?php
$query = $con->query('SELECT inet_ntoa(IP_ADDRESS)as address, FILENAME, country, area, city FROM download WHERE FILENAME is not null ORDER BY country,area,city');
while ($row = $query->fetch())
{
echo "<tr>";
echo "<td>" . $row['$address'] ."</td>";
echo "<td>" . $row['FILENAME'] ."</td>";
echo "<td>" . $row['country'] . "</td>";
echo "<td>" . $row['area'] . "</td>";
echo "<td>" . $row['city'] . "</td>";
echo "</tr>";
}
?>
It no longer throws an error, but the ip's are all wrong, many starting with 0.0.0.
How do I do the conversion so I can display the ip_address correctly?
Thanks in advance,
Larry