BadGoat Posted October 24, 2006 Share Posted October 24, 2006 Hello!I am getting a 0 when echoing the variable from the code snippet below, and I am sure it has something to do with the LIKE portion on the SQL query, but I cannot figure it out.. The goal is to print the percentage of free IPs on our local network, but it's showing a zero. Is the answer glaringly simple?[code] $ipb10 = '10.'; $query1 = "SELECT SUM(no_ips) AS totalip FROM ips WHERE INET_NTOA(sip) LIKE '.$ipb10.' "; $result = mysql_query($query1); $r = mysql_fetch_array($result); $free = 16777216; $pctg1 = ($r['totalip']/$free*100); echo number_format($pctg1, 2);[/code] Link to comment https://forums.phpfreaks.com/topic/24974-like-query-question/ Share on other sites More sharing options...
jvrothjr Posted October 24, 2006 Share Posted October 24, 2006 [code=php:0]LIKE '%.$ipb10.%'[/code] Link to comment https://forums.phpfreaks.com/topic/24974-like-query-question/#findComment-113835 Share on other sites More sharing options...
BadGoat Posted October 24, 2006 Author Share Posted October 24, 2006 I tried that and am still getting a zero =/*EDIT*My own fat finger fault, that works /bonk selfThank you kindly! Link to comment https://forums.phpfreaks.com/topic/24974-like-query-question/#findComment-113842 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.