Jump to content

help with small script please


shergold

Recommended Posts

here is the script, its simple :

 

<?php

// the function

function check($ip, $port)

    {

            $output = @fsockopen($ip, $port, $errno, $errstr, 2);

            if (!$output)

             

            {

              echo "<font color="#FF0000" face="Arial" size="2"><marquee behavior="slide" loop="1">Offline</marquee></font>* ";

             

            } else

           

             {echo "<font color="#00FF00" face="Arial" size="2"><marquee behavior="slide" loop="1">Online</marquee></font>* ";

              @fclose($output);

        }

    }

// to test the function, lets call google's ip

// #### the IP ###### port

check("212.241.207.15", "90");   

   

?>

 

please can someone point out the error and fix it for me, i would appriciate it,

thankyou,

shergold

Link to comment
https://forums.phpfreaks.com/topic/55621-help-with-small-script-please/
Share on other sites

Neatened it up a little:

 

<?php

function check($ip, $port) {

$output = @fsockopen($ip, $port, $errno, $errstr, 2);

if (!$output) {
	echo "<font color=\"#FF0000\" face=\"Arial\" size=\"2\"><marquee behavior=\"slide\" loop=\"1\">Offline</marquee></font>";
} else {
	echo "<font color=\"#00FF00\" face=\"Arial\" size=\"2\"><marquee behavior=\"slide\" loop=\"1\">Online</marquee></font>";
	@fclose($output);
}
}


check("212.241.207.15", "80");   
   
?>

 

Note: use port 80 when testing Google's IP, not 90! Error was you failed to escape the quotes in your echo statements.

You have this:

 

echo "<font color="#FF0000" face="Arial" size="2"><marquee behavior="slide" loop="1">Offline</marquee></font>* ";

 

Use this:

 

echo '<font color="#FF0000" face="Arial" size="2"><marquee behavior="slide" loop="1">Offline</marquee></font>* ';

 

 

Remember that html tags should not have the same string-start character as the echo (" or ')

 

EDIT: Yeah, you can also escape them.

 

FD

YES i know im a "n00b" :P

<html>

<head>

<meta http-equiv="Content-Language" content="en-gb">

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<title>New Page 1</title>

</head>

 

<body>

 

<div style="position: absolute; width: 100px; height: 100px; z-index: 1; border: 1px solid #000000" id="layer1">

<img border="0" src="images/statuspic.jpg" width="400" height="200"></div>

<div style="position: absolute; width: 100px; height: 18px; z-index: 2; left: 272px; top: 199px" id="layer2">

 <script><?php

// the function

function check($ip, $port)

{

$output = @fsockopen($ip, $port, $errno, $errstr, 2);

if (!$output)

 

{

echo '<font color="#FF0000" face="Arial" size="2"><marquee behavior="slide" loop="1">Offline</marquee></font>';

 

} else

 

{echo '<font color="#00FF00" face="Arial" size="2"><marquee behavior="slide" loop="1">Online</marquee></font>';

@fclose($output);

}

}

// to test the function, lets call google's ip

// #### the IP ###### port

check("212.241.207.15", "90");

 

?>

</script>

</div>

 

<div style="position: absolute; width: 100px; height: 18px; z-index: 2; left: 84px; top: 199px" id="layer3">

 

<script>

<?php

// the function

function check($ip, $port)

{

$output = @fsockopen($ip, $port, $errno, $errstr, 2);

if (!$output)

 

{

echo '<font color="#FF0000" face="Arial" size="2"><marquee behavior="slide" loop="1">Offline</marquee></font>';

 

} else

 

{echo '<font color="#00FF00" face="Arial" size="2"><marquee behavior="slide" loop="1">Online</marquee></font>';

@fclose($output);

}

}

// to test the function, lets call google's ip

// #### the IP ###### port

check("212.241.207.15", "90");

 

?>

</script>

</div>

 

</body>

 

</html>

the marquees/text arnt showing, ive changed the file extension to .php what have i done wrong...? lol

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.