mmcdonald 28 Posting Pro

I have nill experience with foreach. Is this right?

$sql = mysql_query("SELECT id from servers WHERE active = '1'");

       $list = array();

                while($ids = mysql_fetch_array($sql)){

                    $list[] = $ids['id'];
                    foreach($list as $id){

                    $get = mysql_query("SELECT * FROM SERVERS WHERE id = ".$id."");
                    $serv = mysql_fetch_array($get);

                    // rest of process here using $serv['cell_ref'] as a reference.

}

This should cycle through all rows. Is that right? (It's not working... so I'm hoping thats written wrong :P )

mmcdonald 28 Posting Pro

I'll give it a shot now, thanks

mmcdonald 28 Posting Pro

Antoher example:

$result = mysql_query("select * from info where idnum = ".$_SESSION['valid'],$conn);

should be:

$result = mysql_query("SELECT * FROM `info` WHERE `idnum` = '".$_SESSION['valid'],$conn."');

(Notice the last few characters...)

mmcdonald 28 Posting Pro

instead of

value=<?php echo $name;?>> 

use:

value=&quot;<?php echo $name;?>&quot;

as &quote allows you to use two quotation marks in the diffent languages HTML and PHP.

Also you have mots of typos like here: value=<?php echo $name;?>> toy have two > at the end.

Didnt manage to geta good looka t the code and I'm dishing up dinner but they're some tips on the go.

mmcdonald 28 Posting Pro

Hey all.

All I need is to collect every id from servers where active ='1' and then cycle the results in a loop right until the end for each individual id.

(I've written this on daniweb, might be typo's or errors.
I'm not interested in code errors it's the process itself)

so...

$sql = mysql_query("SELECT `id` FROM `servers` WHERE `id` = '1'");
$ids = mysql_fetch_array($sql);

foreach ($ids){

// complete the process in these brackets

}

What I dont know is how you write the for each id do this part:

    foreach ($ids){

What do I need to use here to begin the process for each ID?

Thanks in advance!

mmcdonald 28 Posting Pro

It's too true to deny xD

mmcdonald 28 Posting Pro

Thats perfect, thanks! :D

mmcdonald 28 Posting Pro

Wow beatiful answer! I'll work through it now :D thanks!

mmcdonald 28 Posting Pro

I cant use a cron for this task as the script should always be running.

I have a loop that does the following:
1) Gets a SQL row
2) Runs the values through some functions
3) stores new values
4) gets the next row and repeats

This script has to always be running 24/7 to update profiles on my website.

Now I've considered something similar to:

<?php 
ignore_user_abort(1); // run script in background 
set_time_limit(0); // run script forever 
do{ 
   // add the loop functions here
   // ... 
}while(true); 
?>

but I'm looking for any advice as to how I should have this loop running in the background. This is Ubuntu 10.04 LTS and I'm very new to linux.

The process will eventually be executing for 500 - 1000 rows and each execution takes between 0.001 and 10.00 seconds. (90% of the rows take less than 0.05 seconds to execute).

Perhaps there is a way to do 25 - 50 rows in one load and loop through all SQL records 20 - 50 at a time? Or should I stick to individual row execution?

Thanks in advance!

mmcdonald 28 Posting Pro

Are you using a stylesheet too? If so check you haven't got it set in your stylesheet.

If that still doesn't work see if you have any other classes set that could have a border?

Try refreshing your cache?

Is the website hosted on a CDN? That will have a time delay.

mmcdonald 28 Posting Pro

Hi all,

I'm trying to use add-on icons for my form filds (see very bottom: http://twitter.github.com/bootstrap/base-css.html#icons)

The thing is, add-on works great on my page but won't work in my nav.

Any ideas?

My code:

<div class="navbar navbar-fixed-top">
          <div class="navbar-inner">
            <div class="container" style="width: auto">
              <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
              </a>
              <a class="brand" href="#" style="padding-left: 80px;">Digishout Training</a>
              <div class="nav-collapse">
                <ul class="nav">
                  <li class="divider-vertical"></li>
                  <li><a href="#"><i class="icon-home"></i> Home</a></li>
                  <li class="divider-vertical"></li>
                  <li><a href="#"><i class="icon-check"></i> Pricing</a></li>
                  <li class="divider-vertical"></li>    
                  <li><a href="#"><i class="icon-envelope"></i> Support</a></li>
                  <li class="divider-vertical"></li>
                </ul>
                <ul class="nav pull-right">
          <li class="divider-vertical"></li>
          <li><a href="/users/sign_up"><i class="icon-pencil"></i> Sign Up</a></li>
          <li class="divider-vertical"></li>
          <form class="navbar-form pull-left">
              <input type="text" class="span2">
              <input type="password" class="span2">
              <button type="submit" class="btn">Login</button>
          </form>
          <li class="divider-vertical"></li>
        </ul>
        </div>
      </div>
    </div>
                </ul>
              </div><!-- /.nav-collapse -->
            </div><!-- /.container -->
          </div><!-- /navbar-inner -->
        </div><!-- /navbar -->
mmcdonald 28 Posting Pro

Hi all,

I have a menu on the left side of my design. When the user scrolls and the object hits the top of the screen I want it to float there. I have the float working fine now, but how can I say "Only float when you meet the top of the display?"

This is the CSS for the object:

.well {
  min-height: 20px;
  padding: 19px;
  margin-bottom: 20px;
  background-color: #f5f5f5;
  border: 1px solid #e3e3e3;
  -webkit-border-radius: 4px;
     -moz-border-radius: 4px;
          border-radius: 4px;
  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
     -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
          box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
            position:fixed !important;
            position: absolute; /*ie6 */
}

Thanks in advance,
Michael

mmcdonald 28 Posting Pro

Okay thanks, I'll probably head down this route. I had it on paper but chose the folder structure method

mmcdonald 28 Posting Pro

This is a website where the user registers thieir own directory such as directory.com/username and that is their own profile area. When they register they first choose a template and this is copied and renamed to their username. Then they completea few forms to customise their own profile.

Better methods?

mmcdonald 28 Posting Pro

Hey all,

I have a folder called 'templates' in my root dir (../templates/). When a PHP form is submitted I want to copy a folder out of 'templates' called 'template1' (../templates/template1) and paste it into the root directory but with the new name of 'username123'.

How can I copy, rename and paste a folder from one dir to another using PHP?

I have read the manuals for copy and rename but some snippets (non working examples are cool too) would be really useful.

Thanks!

mmcdonald 28 Posting Pro

I've actually solved my issue, but if anyone has any additional advice I'd love to hear it. Thanks!

mmcdonald 28 Posting Pro

I'm hoping not to post much code (to do this myself) but I'm having issues in figuring out why a mysql_query isn't be executed.

This is the mysql_query:

mysql_query("UPDATE `servers` SET 
`status` = 'online.png', 
`cur_players` = '".$online_count."',
`max_players` = '".$max_slots."',
`software` = '".$software."',
`plugins` = '".$plugins2."',
`players` = '".$players2."',
`version` = '".$version."',
`query_enabled` = '0',
`last_check` = '".$time_now."',
`uptime` ='".$add_up."',
`gametype` = '".$gametype."',
`map` = '".$map."'
WHERE `id` = '".$serv['id']."'");

Now before the query I have set '$i = '0';. This query is in a block, so in the same block after the query I have set $i = '1';. Then I echo $i outside of the block at the end of the script and it hs the value of '1'. So I know the block is being executed right?

All errors are on, no where have I turned off error reporting. Yet no errors are reported at all?

Any other valuable methods of troubleshooting I could learn / use?

Thanks in advance for any help!

mmcdonald 28 Posting Pro

In a SQL field I have this:

GroupManager 2.0 (2.9.3) (Phoenix)<br/>MultiInv 3.1.3<br/>Ptweaks 4.2<br/>WorldEdit 1232-0bc9369

Which spits out this:

GroupManager 2.0 (2.9.3) (Phoenix)
MultiInv 3.1.3
Ptweaks 4.2
WorldEdit 1232-0bc9369
Multiverse-NetherPortals 2.4-b530

How can I make it so it's two text columns like this when I echo it onto a page:

GroupManager 2.0 (2.9.3) (Phoenix)               WorldEdit 1232-0bc9369
MultiInv 3.1.3                                   Multiverse-NetherPortals 2.4-b530
Ptweaks 4.2

I've done my searches with no results :/

mmcdonald 28 Posting Pro

Thanks Ill try that now :)

mmcdonald 28 Posting Pro

Thats what I'm asking, how can I store them? Its just storing 'Array'

mmcdonald 28 Posting Pro
$plugins = $Server->Get('plugins');
   echo "<br /><br /><b>Plugins</b><br> ";
         foreach($plugins as $plugin) {
                 echo $plugin."<br>";
         }

That snippet above spits out a long list of plugins from a server. How can I store each plugin listed into SQL so that its stored as '$plugin[0]<br/>$plugin[1]<br/>$plugin[2]<br/>' and so on so that when I echo out somewhere its a nice list...?

Thanks in advance! :P

mmcdonald 28 Posting Pro

Sorry people but I'm really struggling with this and I don't know why... but still.

I have a stored unix timestamp. [a]
I have the current timestamp not in unix format (YYYY-MM-DD HH:MM:SS) [b]

I need to:
1) convert the current timestamp [b] into a unix timestamp
2) I need to take the stored timestamp away from the newly created timestamp
3) I need to add the converted timestamp onto the stored timestamp.

This is for an uptime counter that uses days hours minutes and seconds, not %.

Thanks :)

mmcdonald 28 Posting Pro

Found this beauty on php.net user submissions:

function date_diff($start, $end="NOW")
{
        $sdate = strtotime($start);
        $edate = strtotime($end);

        $time = $edate - $sdate;
        if($time>=0 && $time<=59) {
                // Seconds
                $timeshift = $time.' seconds ';

        } elseif($time>=60 && $time<=3599) {
                // Minutes + Seconds
                $pmin = ($edate - $sdate) / 60;
                $premin = explode('.', $pmin);

                $presec = $pmin-$premin[0];
                $sec = $presec*60;

                $timeshift = $premin[0].' min '.round($sec,0).' sec ';

        } elseif($time>=3600 && $time<=86399) {
                // Hours + Minutes
                $phour = ($edate - $sdate) / 3600;
                $prehour = explode('.',$phour);

                $premin = $phour-$prehour[0];
                $min = explode('.',$premin*60);

                $presec = '0.'.$min[1];
                $sec = $presec*60;

                $timeshift = $prehour[0].' hrs '.$min[0].' min '.round($sec,0).' sec ';

        } elseif($time>=86400) {
                // Days + Hours + Minutes
                $pday = ($edate - $sdate) / 86400;
                $preday = explode('.',$pday);

                $phour = $pday-$preday[0];
                $prehour = explode('.',$phour*24); 

                $premin = ($phour*24)-$prehour[0];
                $min = explode('.',$premin*60);

                $presec = '0.'.$min[1];
                $sec = $presec*60;

                $timeshift = $preday[0].' days '.$prehour[0].' hrs '.$min[0].' min '.round($sec,0).' sec ';

        }
        return $timeshift;
}

// EXAMPLE:

$start_date = 2010-03-15 13:00:00
$end_date = 2010-03-17 09:36:15

echo date_diff($start_date, $end_date);

?>

"
Returns: 1days 20hours 36min 15sec
Can be taken up to centuries - if you do the calculations.

Hope this finally helps someone! :D
"
Will test and if it works mark as resolved :)

mmcdonald 28 Posting Pro

Just to check that I'm following you right...

This:

$last_check_query = mysql_query("SELECT last_check from servers_updowntime where serverid = ".$serv_id."");
     $last_check = mysql_fetch_array($last_check_query);
     $time_since_last_check = (date("Y-m-d H:i:s") - $last_check[0]);
     $hms = ($time_since_last_check - date("Y-m-d H:i:s"));
            function time2seconds($time='00:00:00')
            {
                list($hours, $mins, $secs) = explode(':', $time);
                return ($hours * 3600 ) + ($mins * 60 ) + $secs;
            }

Would become this:

$last_check_query = mysql_query("SELECT last_check from servers_updowntime where serverid = ".$serv_id."");
     $last_check = mysql_fetch_array($last_check_query);
     $time_since_last_check = (strtotime(date("Y-m-d H:i:s")) - $last_check[0]);
     $hms = ($time_since_last_check - strtotime(date("Y-m-d H:i:s")));
            function time2seconds($time='00:00:00')
            {
                list($hours, $mins, $secs) = explode(':', $time);
                return ($hours * 3600 ) + ($mins * 60 ) + $secs;
            }

?

mmcdonald 28 Posting Pro

Thanks gents, I'll try them both :)

mmcdonald 28 Posting Pro

Hi all,

I have two dates:

1 = $last_check = YYYY-MM-DD HH:MM:SS (A SQL value)
2 = $datetime = YYYY-MM-DD HH:MM:SS (Called using PHP)

How can I take away 1 from 2 and convert the minutes and seconds left over into seconds?

Basically I'm running an uptime counter script that will cycle through about 1000 servers. What I'm going to do is get the number of seconds since it was last checked, and if its online add them to the uptime counter in SQL and if its offline add them to the downtime counter in SQL.

It will be never be more than a few minute since the last check.

Should I use something like explode or is there a cleaner way of doing this? :

     $last_check_query = mysql_query("SELECT last_check from servers_updowntime where serverid = ".$serv_id."");
     $last_check = mysql_fetch_array($last_check_query);
     $time_since_last_check = (date("Y-m-d H:i:s") - $last_check[0]);
     $hms = ($time_since_last_check - date("Y-m-d H:i:s"));

            function time2seconds($time='00:00:00')
            {
                list($hours, $mins, $secs) = explode(':', $time);
                return ($hours * 3600 ) + ($mins * 60 ) + $secs;
            }
mmcdonald 28 Posting Pro

Sure :)

1) Connect to DB. Get the lowest id and the highest id from table 'servers'
2) Get the lowest id and find the ip and port from that row
3) run the IP and Port through the function : MinecraftQuery
4) store the results of that function
5) Go to the next highest id in the servers table
6) If step 5 is greater than the highest id then start fro the lowest id
7) if step 5 isn't greater than the highest id, run the current id through the function MinecraftQuery.

Therefore one page load completed the function for one id.

Something like :

Set the current id as $cur_id
When you've completed this go to:

this_file.php?next_id=($cur_id +1)

Then use $_get['next_id'] to do the next row and so on.

But I need to ensure that A) the id exists and B) it goes back to the lowest id when the cycle reaches the highest id.

mmcdonald 28 Posting Pro

now the last updated timestamp isn't a bad idea! Sorry about my stupidity - I started teching myself PHP a few weeks back and I'm yet to book a course ;)

I was originally thinking of something along the lines of:

          $prev_id = $_GET['prev_id']; 
          $cur_id = "SELECT id FROM servers WHERE id > ".$prev_id." ORDER BY id ASC LIMIT 1";

but your timestamp idea is pretty genius :P

If I was to do it by timestap I could then select 10 id's that haven't been processed in the past 2 minutes and limit the execution to 10. Then get the next 10 and so on...

I'm still conviced that I'm doing this entierly wrong :/

mmcdonald 28 Posting Pro

Whilst I have the attention of a genius poster ( ;) ) could I please ask your advice on the code below. It's supposed to find the lowest id and then run the process, then add 1 to the id, see if that new id exists and then run the process for that new id. BUT if the id doesnt exist it goes back to id = 0 and then speeds through numbers. Could you add the if id exists part to this for me please?

    <?php
/*
if ($_SERVER['SERVER_ADDR'] != '::1'){
echo"You are not authorised to execute this script";
}else{
   */
           include('../config.php');

    // Identify the last IP that was checked, then use that to find the next one to check using previous id + 1
    class MinecraftQuery 
    {
        public static function query($address, $port, $timeout) 
        {
            $socket = @fsockopen($address, $port, $timeout);

            if (!$socket) {
             // If an error occurs, make current_players = 0, then crry on to next id
             mysql_query("UPDATE servers SET cur_players='0' WHERE ip='".$address."'");
             echo('
            <script type="text/javascript">
            window.location.replace("player_count2.php?prev_id='.$cur_id.'");
            </script>
            ');

            }else{

            fwrite($socket, chr(254));

            $response = "";

            while(!feof($socket)) $response .= fgets($socket, 1024);

            //$result = array();
            $response = str_replace(chr(0),"",$response);
            $response = substr($response, 2);
            $query = preg_split("[".chr(167)."]", $response);

            //$result['hostname'] = ($query[0]);
            $result ['Players'] = (int) $query[1];
            $result['/'] = (int) $query[2];

            echo($query[1]."/".$query[2]);
            // After writing current players and max players to SQL, carry on to next id
            mysql_query("UPDATE servers SET cur_players=".$query[1].", max_players=".$query[2]." WHERE ip='".$address."'");
            echo('
            <script type="text/javascript">
            window.location.replace("player_count2.php?prev_id='.$cur_id.'");
            </script>
            ');
            }

        }
    }         


              $min_server1 = mysql_query("SELECT MIN(id) FROM servers");
              $min_server = mysql_fetch_array($min_server1); …
mmcdonald 28 Posting Pro

The fastest you can execute tasks in the schedular is 1 minute. I need the function above executed every 1 - 10 seconds

mmcdonald 28 Posting Pro

It's a Windows server :(

mmcdonald 28 Posting Pro

It's not actually resolved but I didn't expect a reply so I saw that as the only way of closing it :3

mmcdonald 28 Posting Pro

This is what the code currently is:

<meta http-equiv="refresh" content="180"/>
<?php

if ($_SERVER['SERVER_ADDR'] != '::1'){
echo"You are not authorised to execute this script";
}else{

           include('../config.php');

    set_time_limit(0);        
    class MinecraftQuery 
    {
        public static function query($address, $port, $timeout) 
        {
            $socket = @fsockopen($address, $port, $timeout);

            if (!$socket) {

             echo("Error.");
             mysql_query("UPDATE servers SET cur_players='0' WHERE ip='".$address."';");

            }else{

            fwrite($socket, chr(254));

            $response = "";

            while(!feof($socket)) $response .= fgets($socket, 1024);

            //$result = array();
            $response = str_replace(chr(0),"",$response);
            $response = substr($response, 2);
            $query = preg_split("[".chr(167)."]", $response);

            //$result['hostname'] = ($query[0]);
            $result ['Players'] = (int) $query[1];
            $result['/'] = (int) $query[2];

            echo($query[1]."/".$query[2]);
            mysql_query("UPDATE servers SET cur_players=".$query[1].", max_players=".$query[2]." WHERE ip='".$address."';");

            }

        }
    }

              $servers = mysql_query("SELECT server_name, port, ip FROM servers where enabled = 1 AND active= 1;");
              $num_rows = mysql_num_rows($servers);

            if ($num_rows > 0) {
                while ($serv = mysql_fetch_array($servers)) {
                echo(''.$serv['server_name'].' : ');
                MinecraftQuery::query($serv['ip'], $serv['port'], 2);
                echo('<br /><br />');

                    }
                }
                header('Location: player_count.php');
                }
?>
mmcdonald 28 Posting Pro

Could anyone rewrite the code above using cURL? I'd love to see how it works and what the difference is.

Thanks,
MM

mmcdonald 28 Posting Pro

Hey thanks for helping me so much :)

This is my new code that does actually do all of the servers without failing or timing out. But I know there are much more efficient methods. I will look into using cURL but I have no experience with AJAX. Where should I start? I have done many manually I I watched the results of a few cycles yesterday. It's updaing the website well now - but I;m only on 14 of 1000's of servers :(

Might need to pay a developer for this one

mmcdonald 28 Posting Pro

Okay so here it is.

The code below is my player counter for a game called Minecraft. It connects to a server and brings back 2 values. 1) The number of current online players and 2) the maximum number of player slots.

Then it stores these two variables in to SQL against the server so that I may use them anywhere on the website like: 'Player: 40/100'.

Now the problem is that it takes far too long for one server to reply that it drops out. 8 - 10 servers are updated but the rest are left. What would be great is a method of starting the process, getting 1 ip, get the results, store the results, close the process and repeat. This does them all on one execution.

The perfect script for my needs would:

1) Open a connection to IP #1 allowing 5000ms for a connection
2) Get the data from IP #1 allowing 5000ms
3) Store the data in SQL
4) Close the connection to IP #1
5) Open a connection to IP #2 allowing 5000ms
6) repeat and so on...

The big question: is there a way to get my server to run this check for a few servers at the same time but starting from ((max_id - min_id) / 2).

So it can do 1000 servers in the same time it takes to do 500 as one script stars from id 1 and the other starts from id 500.

Look …

mmcdonald 28 Posting Pro

Okay so here it is.

The code below is my player counter. It connects to a server and brings back 2 values. 1) The number of current online players and 2) the maximum number of player slots.

Then it stores these two variables in to SQL against the server so that I may use them anywhere on the website like: 'Player: 40/100'.

Now the problem is that it takes far too long for one server to reply that it drops out. 8 - 10 servers are updated but the rest are left. What would be great is a method of starting the process, getting 1 ip, get the results, store the results, close the process and repeat. This does them all on one execution. Any ideas?

<meta http-equiv="refresh" content="60">
<?php

if ($_SERVER['SERVER_ADDR'] != '::1'){
echo"You are not authorised to execute this script";
}else{

       include('../config.php');


class MinecraftQuery 
{
    public static function query($address, $port, $timeout) 
    {
        $socket = @fsockopen($address, $port, $timeout);

        if (!$socket) {

         echo("Error.");
         mysql_query("UPDATE servers SET cur_players='0' WHERE ip='".$address."';");

        }else{

        fwrite($socket, chr(254));

        $response = "";

        while(!feof($socket)) $response .= fgets($socket, 1024);

        //$result = array();
        $response = str_replace(chr(0),"",$response);
        $response = substr($response, 2);
        $query = preg_split("[".chr(167)."]", $response);

        //$result['hostname'] = ($query[0]);
        $result ['Players'] = (int) $query[1];
        $result['/'] = (int) $query[2];

        echo($query[1]."/".$query[2]);
        mysql_query("UPDATE servers SET cur_players=".$query[1].", max_players=".$query[2]." WHERE ip='".$address."';");

        }

    }
}

          $servers = mysql_query("SELECT server_name, port, ip FROM servers where enabled = 1 AND active= 1;");
          $num_rows = mysql_num_rows($servers);

        if ($num_rows > 0) {
            while ($serv = mysql_fetch_array($servers)) {
            echo(''.$serv['server_name'].' : ');
            MinecraftQuery::query($serv['ip'], $serv['port'], …
mmcdonald 28 Posting Pro

I'll do all of that now and get back to you. memcache?

mmcdonald 28 Posting Pro

Thanks for your reply. It's a function that contacts a gaming server and and asks for the number of players online. I've tried everything you've mentioned above - I just want to try and make it run individually for each server IP. There are 100's of servers.

mmcdonald 28 Posting Pro

Hi all,

I have an issue with a loop as it contains communication between my server and a remote one. If the remote server has an issue then it takes forever to complete the loop and the execution times out.

What it currently is:

          $servers = mysql_query("SELECT * FROM server_tab;e where s_enabled = 1 AND s_active= 1;");
          $num_rows = mysql_num_rows($servers);

        if ($num_rows > 0) {
            while ($server_ip = mysql_fetch_array($servers)) {
            echo(''.$server_ip['server_name'].': ');
            communicationQuery::query($server_ip['ip']);
            echo('<br /><br />');

                }
            }
            echo"All communcations completed. Waiting for META refresh...";
            }

The process I want:
1) open process
2) complete the query for ip 1
3) store results
4) close process
then repeat for IP 2, 3, 4 and so on.

Any ideas?

mmcdonald 28 Posting Pro

Resolved it. Was an error ina account.php where a num_row was expected to be resourse :P thanks all!

mmcdonald 28 Posting Pro

Just to note, also tried != 0 and > 0 here:

if ($auth_check == 1) {
mmcdonald 28 Posting Pro

Hey all,

This website is a directory and the problem is authenticating users to edit a server, even after they've logged in. The idea is to stop any SQL mix-ups due to my weak code (I'm learning PHP).

When they click 'Edit' next to the server after logging in they are directed to "update-server.php?server=$server_id".

When they arrive at "update-server.php" this code runs:

    //This session value is created at login
    $username = $_SESSION['valid'];

    //This is written to the URL
    $server_id = $_GET['server'];

    //See if a server exists with this ID and Username
    $query_server = "SELECT id FROM servers WHERE id='".$server_id."' AND `administrator`='".$username."'";
    $result=mysql_query($query_server);
    $auth_check=mysql_num_rows($result);

    // If a row is found where id and username match show form
    if ($auth_check == 1) {

    // FORM HERE

    }else{

    //Take user back to their account
    header('location: account.php');

    }

Now heres the problem. I've purposely added servers under the account that don't below to me and servers that do. However they both send me back to account.php?

Any ideas? :)

Thanks in advance!