shergold Posted June 14, 2007 Share Posted June 14, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/55621-help-with-small-script-please/ Share on other sites More sharing options...
Full-Demon Posted June 14, 2007 Share Posted June 14, 2007 Ok thank you for posting a simple script. You have a reasons for posting it? Perhaps errors? What errors? What problems? FD Quote Link to comment https://forums.phpfreaks.com/topic/55621-help-with-small-script-please/#findComment-274843 Share on other sites More sharing options...
shergold Posted June 14, 2007 Author Share Posted June 14, 2007 i keep gettin an error for the line that the first echo is on. Quote Link to comment https://forums.phpfreaks.com/topic/55621-help-with-small-script-please/#findComment-274845 Share on other sites More sharing options...
chigley Posted June 14, 2007 Share Posted June 14, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/55621-help-with-small-script-please/#findComment-274846 Share on other sites More sharing options...
Full-Demon Posted June 14, 2007 Share Posted June 14, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/55621-help-with-small-script-please/#findComment-274847 Share on other sites More sharing options...
shergold Posted June 14, 2007 Author Share Posted June 14, 2007 thankyou very much, im just starting to learn php. Quote Link to comment https://forums.phpfreaks.com/topic/55621-help-with-small-script-please/#findComment-274848 Share on other sites More sharing options...
Full-Demon Posted June 14, 2007 Share Posted June 14, 2007 Every one here did FD Quote Link to comment https://forums.phpfreaks.com/topic/55621-help-with-small-script-please/#findComment-274850 Share on other sites More sharing options...
shergold Posted June 14, 2007 Author Share Posted June 14, 2007 YES i know im a "n00b" <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 Quote Link to comment https://forums.phpfreaks.com/topic/55621-help-with-small-script-please/#findComment-274867 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.