Re: Still trying to figure this out...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, June 20, 2006 1:37 am, Rob W. wrote:
> I still have not yet found anybody to help me with this. All the code
> that
> people have given me has not worked at all. I still get no output. So
> to add
> a little more to this, I'm gonna define how the database looks.
>
> ----------------------------------
> |    switchid        |    switchport     |
> ----------------------------------
> |            1          |             1          |
> |            1          |             2          |
> |            1          |             3          |
> |            1          |             4          |
> |            1          |             7          |
> |            1          |             10        |
> ----------------------------------
>
> ect so on and so forth. There are other switch id's in there as well
> along
> with their switch port's which sorting the other switchid's is not a
> problem. I also know the maximum amount for each switchid so that's
> not a
> problem as well. I need to be able to display the missing numbers in
> there.
> I have no extra spaces in there for blank numbers. After a server has
> been
> entered in to the database, it take's that number that was not shown
> previously in the database and enters it in, there for displaying it
> and not
> making it available for the next time another server is added. I have
> no way
> to alter the database as I am trying to clone a program and this is
> the only
> thing haning me up as of right now. If I can find someone to solve
> this
> problem for me, I will be glad to send money via paypal for helping
> out
> solving this problem as I have been on it for 2 days now and this is
> the
> last bit of code for this program that is holding me up. Please read
> below
> for more information on what I am doing.

Here's the first problem I am seeing...

Between the time that you search for an "open" port and you then
assign it to something, ANOTHER script might run, get the same "open"
port, and then assign it to something.

That's pretty much your basic "race condition" right there.

If you've got that all solved, then I would go for a crude solution,
personally.

<?php
  $query = 'select switchport from switches where switchid = 1 order
by switchport';
  $used = mysql_query($query) or die(mysql_error());
  $last_used = 0;
  while (list($port) = mysql_fetch_row($used)){
    for ($p = $last_used + 1; $p < $port; $p++){
      echo "$p is open<br />\n";
    }
    $last_used = $port;
  }
?>

But I'm a crude kind of guy, so there you go.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux