skip to Main Content

edit : We found out from the detailed research that cpu overdue drops to 503 when there is instant density due to bad script. Thank you to all the responses.


my ecommerce php index page script add google snippets ld+json java script works after a while gives an error(503 Service Unavailable) .

I’m saving the php display_errors tick over cPanel I am saving again. Works okey. Then, after a while, it suddenly gives an error of 503. After removing the javascript code from the page it does not give any more errors when I clear the cache.

create in my function file :

 function GoogleSnippetsWebsite($snippets) {
     $out ='<script type="application/ld+json">{'."n";
     $out.='"@context":"https://schema.org",'."n";
     $out.='"@type": "WebSite",'."n"; 
     $out.='"url": "https://www.-----.com",'."n";
     $out.='"name":"----.com",'."n";
     $out.=' "inLanguage":"en-US",'."n";  
     $out.=' "sameAs":['."n";
     $out.=' "https://www.---.com/",'."n";  
     $out.=' "https://www.---.com/" ],'."n";
     $out.=' "potentialAction": {'."n";
     $out.='"@type": "SearchAction",'."n";
     $out.='"target": "https://www.----.com/search=&src={search_term_string}",'."n";  
     $out.='"query-input": "required name=search_term_string"}}'."n";  
     $out.='</script>'."n";    
     return $out; 
}

I want to show my php page:

<head>  
    <?php echo GoogleSnippetsWebsite('website'); ?>
</head>

Works for 5 minutes. after 503 Service Unavailable.

maybe very simple but I can not solve. I didn’t get results on google searches. What are your suggestions? Thank you.

503 Service Unavailable

2

Answers


  1. Often HTTP 503 (Service Unavailable) is an error when the server has too few recources to execute the request what you want to do. Looking at your question this seems the case aswell since that it works for a couple of minutes before the server returns this error message.

    Make sure that you have enough bandwith and storage ect to use.
    A solution for this would be to get a host where you don’t have these limitations

    Login or Signup to reply.
  2. You first use $deger then $out, so the $out string don’t have the first line.

    Be careful as you did not initiate $out first, it must be where the 503 error comes from.

    For a better readability, I suggest avoid using $out.= on each line, just use a point to concatenate at the begining and remove every semicolon at the end (except the last concatenation).

    function GoogleSnippetsWebsite($snippets) {
        $out ='<script type="application/ld+json">{'."n"
            .'"@context":"https://schema.org",'."n"
            .'"@type": "WebSite",'."n";
            .'"url": "https://www.-----.com",'."n"
            .'"name":"----.com",'."n"
            .' "inLanguage":"en-US",'."n"
            .' "sameAs":['."n"
            .' "https://www.---.com/",'."n"
            .' "https://www.---.com/" ],'."n"
            .' "potentialAction": {'."n"
            .'"@type": "SearchAction",'."n"
            .'"target": "https://www.----.com/search=&src={search_term_string}",'."n"
            .'"query-input": "required name=search_term_string"}}'."n"
            .'</script>'."n";
    
        return $out; 
    }
    

    And I’d say I personaly use PHP_EOL instead of "n" 😉

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search