Jump to content


Photo

LIKE query question


  • Please log in to reply
2 replies to this topic

#1 BadGoat

BadGoat
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 24 October 2006 - 08:19 PM

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?
    $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);


#2 jvrothjr

jvrothjr
  • Members
  • PipPipPip
  • Advanced Member
  • 300 posts
  • LocationOhio

Posted 24 October 2006 - 08:44 PM

LIKE '%.$ipb10.%'

If you understand everything you know nothing!

http://rcchjr.awardspace.com/

#3 BadGoat

BadGoat
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 24 October 2006 - 08:49 PM

I tried that and am still getting a zero =/

*EDIT*

My own fat finger fault, that works

/bonk self

Thank you kindly!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users