Hi guys, I have a problem with the script. There is a parse error in line 7 which it end of the line. I need your help to make them get correct, as I am not a programmer and know very little PHP. Here it is the code: <?php try { include_once('HideUrlConfig.php'); } ?> PHP: Parse error: syntax error, unexpected $end, expecting T_CATCH in /home/username/public_html/mysite.com/myscript.php on line 6 What do I needs to change it with?
Thanks guardian999, so I want to add the error message in the catch exception that if the server is gone down? I want to add the error message which something is like "the server is down at the moment, please try again later" Thanks, Mark
try { include_once('HideUrlConfig.php'); } catch (Exception $e) { echo "The server is down. Please try again later .."; } PHP:
Thanks Internet Monk, so how could I get rid of the 404 not found that says in the webpage: I only wants to display the message by the catch expection: Here it is the source code: <?php try { $homepage = file_get_contents('http://www.myanothersite.com/script1.php'); echo $homepage; }catch(Exception $E){} echo "The server is down. Please try again later .."; ?> PHP:
if ($homepage = @file_get_contents("http://www.domain.com")) { echo $homepage; } else { echo "The server is down. Please try again later .."; } PHP:
Thanks, but it still showing the message like below... So I only want to display the message without "Not Found The requested URL /script1.php was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request." Which I means that I only want to displaying the message: Here it is the update php that I am using: <?php if ($homepage = @file_get_contents("http://www.mysite.com/script1.php")) { echo $homepage; } else { echo "The server is down. Please try again later .."; } ?> PHP: Any idea?
i dont sure this will work but some time i also have a problem like this. if your editor is not high lighted the syntax because of space between <?php ?> tags.So write the code like this <?php try { include_once('HideUrlConfig.php'); } ?> i hope this will work for you
Use curl. It's a swiss-army-knife <?php if (!function_exists('curl_init')) { echo 'Curl is not enabled.'; exit(); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://localhost/test.php'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_TIMEOUT, 94); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 94); $res = curl_exec($ch); $info = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); // HTTP Code checking if ($info == 200) { echo 'Everything is fine.'; echo $res;// this is the URL content } else if ($info == 404) { echo 'The server is down. Please try again later ..'; } else { echo 'The server has '.$info.' error. Please try again later ..'; } ?> PHP: