winmastergames Posted October 27, 2007 Share Posted October 27, 2007 hi i made a script it checks if a webserver is online if it is i want it to echo a link that there click on to redirect to another site but its not working heres the script <?php function prepWWW($url) { $replace = array("http://" => "", "www." => ""); foreach($replace as $toReplace=>$replaceWith) { $url = str_replace($toReplace, $replaceWith, $url); } $parts = explode("/", $url); $newURL = strip_tags(addslashes($parts[0])); return $newURL; } $site = prepWWW("winmastergames.com"); $check = @fsockopen($site, 80); if($check) { echo "<a href="index.htm">ENTER INDEX</a>"; } else { echo "<a href="backup.htm">ENTER BACKUP</a>"; } ?> WHAT is wrong Quote Link to comment https://forums.phpfreaks.com/topic/75042-solved-php-server-monitor-script/ Share on other sites More sharing options...
marcus Posted October 27, 2007 Share Posted October 27, 2007 1. Give us an error. 2. You need to escape the links. echo "<a href=\"link\">ENTER here</a>"; Quote Link to comment https://forums.phpfreaks.com/topic/75042-solved-php-server-monitor-script/#findComment-379470 Share on other sites More sharing options...
winmastergames Posted October 27, 2007 Author Share Posted October 27, 2007 Oh sorry here is the error Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\xampp\htdocs\online.php on line 16 Quote Link to comment https://forums.phpfreaks.com/topic/75042-solved-php-server-monitor-script/#findComment-379517 Share on other sites More sharing options...
cooldude832 Posted October 27, 2007 Share Posted October 27, 2007 also its customairy to display what line it is if you have an line number error i.e error on line 16 it sucked line 16 is: echo "asdf"; Quote Link to comment https://forums.phpfreaks.com/topic/75042-solved-php-server-monitor-script/#findComment-379518 Share on other sites More sharing options...
winmastergames Posted October 30, 2007 Author Share Posted October 30, 2007 Ok thats now fixed but now i uploaded to awardspace or 110mb and it always says that the servers offline is there something else wrong or is there i better way i can make this script? so it works on all servers Note:it works on my own server using Xampp Quote Link to comment https://forums.phpfreaks.com/topic/75042-solved-php-server-monitor-script/#findComment-381004 Share on other sites More sharing options...
aschk Posted October 30, 2007 Share Posted October 30, 2007 The answer to your question is most likely the following : Your host has disabled the fsockopen function in the PHP.ini file, and too rightly too. Imagine what happens when lots of amateur programmers start creating sockets and not closing them... Quote Link to comment https://forums.phpfreaks.com/topic/75042-solved-php-server-monitor-script/#findComment-381016 Share on other sites More sharing options...
winmastergames Posted October 30, 2007 Author Share Posted October 30, 2007 oh thats really annoying does anyone know a free host that will have it open? Quote Link to comment https://forums.phpfreaks.com/topic/75042-solved-php-server-monitor-script/#findComment-381017 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.