www.webdeveloper.com
Results 1 to 15 of 15

Thread: 500 Internal Server Error

  1. #1
    Join Date
    Nov 2006
    Posts
    250

    500 Internal Server Error

    I don't understand why I'm getting this error...I just uploaded a complete website from my test server (hosted by SiteGround) to the main server (hosted by GoDaddy), and I never got this error on the test server. What do I do?

    http://www.ccgulfbreeze.com/contact/

  2. #2
    Join Date
    Jun 2007
    Posts
    348
    Submit a ticket to GoDaddy.

  3. #3
    Join Date
    May 2003
    Posts
    598
    Or post the code on the page.
    We do precision guesswork

  4. #4
    Join Date
    Nov 2006
    Posts
    250
    I submitted a ticket to GoDaddy and they said it was my coding, but I dont think so...the same page worked fine on my server hosted by siteground. But anyways heres my coding.

    PHP Code:
    <?php
    $title  
    =  "Us";
    $image  =  "Contact-Us";
    $width  =  "128";
    $height  =  "19";

    switch (
    $_GET['who']){
    case 
    john:
    $title  =  "Pastor John";
    $contact  =  "checked";
    $john  =  "selected";
    $image  =  "contactJohn";
    $width  =  "237";
    $height  =  "18";
    break;

    case 
    steve:
    $title  =  "Steve Feeley";
    $contact  =  "checked";
    $steve  =  "selected";
    $image  =  "contactSteve";
    $width  =  "251";
    $height  =  "23";
    break;

    case 
    doug:
    $title  =  "Doug Kimsal";
    $contact  =  "checked";
    $doug  =  "selected";
    $image  =  "contactDoug";
    $width  =  "245";
    $height  =  "23";
    break;

    case 
    randy:
    $title  =  "Randy Pitman";
    $contact  =  "checked";
    $randy  =  "selected";
    $image  =  "contactRandy";
    $width  =  "265";
    $height  =  "23";
    break;

    case 
    joe:
    $title  =  "Joe Prestridge";
    $contact  =  "checked";
    $joe  =  "selected";
    $image  =  "contactJoe";
    $width  =  "267";
    $height  =  "23";
    break;

    case 
    bob:
    $title  =  "Bob Rockwell";
    $contact  =  "checked";
    $bob  =  "selected";
    $image  =  "contactBob";
    $width  =  "258";
    $height  =  "19";
    break;

    case 
    neil:
    $title  =  "Neil Spencer";
    $contact  =  "checked";
    $neil  =  "selected";
    $image  =  "contactNeil";
    $width  =  "251";
    $height  =  "23";
    break;

    case 
    dale:
    $title  =  "Dale Waltman";
    $contact  =  "checked";
    $dale  =  "selected";
    $image  =  "contactDale";
    $width  =  "270";
    $height  =  "19";
    break;

    case 
    brenton:
    $title  =  "Brenton Collyer";
    $contact  =  "checked";
    $brenton  =  "selected";
    $image  =  "contactBrenton";
    $width  =  "281";
    $height  =  "23";
    break;

    case 
    austin:
    $title  =  "Austin Bodiford";
    $contact  =  "checked";
    $austin  =  "selected";
    $image  =  "contactAustin";
    $width  =  "276";
    $height  =  "19";
    break;

    case 
    jill:
    $title  =  "Jill Brogdon";
    $contact  =  "checked";
    $jill  =  "selected";
    $image  =  "contactJill";
    $width  =  "235";
    $height  =  "23";
    break;

    case 
    terri:
    $title  =  "Terri Busey";
    $contact  =  "checked";
    $terri  =  "selected";
    $image  =  "contactTerri";
    $width  =  "221";
    $height  =  "23";
    break;

    case 
    cd:
    $title  =  "C.D. Corbin";
    $contact  =  "checked";
    $cd  =  "selected";
    $image  =  "contactCd";
    $width  =  "238";
    $height  =  "19";
    break;

    case 
    chad:
    $title  =  "Chad Erwins";
    $contact  =  "checked";
    $chad  =  "selected";
    $image  =  "contactChad";
    $width  =  "245";
    $height  =  "19";
    break;

    case 
    carol:
    $title  =  "Carol Feeley";
    $contact  =  "checked";
    $carol  =  "selected";
    $image  =  "contactCarol";
    $width  =  "250";
    $height  =  "23";
    break;

    case 
    brad:
    $title  =  "Brad Feeley";
    $contact  =  "checked";
    $brad  =  "selected";
    $image  =  "contactBrad";
    $width  =  "255";
    $height  =  "19";
    break;

    case 
    paul:
    $title  =  "Paul Kimsal";
    $contact  =  "checked";
    $paul  =  "selected";
    $image  =  "contactPaul";
    $width  =  "231";
    $height  =  "19";
    break;

    case 
    keith:
    $title  =  "Keith King";
    $contact  =  "checked";
    $keith  =  "selected";
    $image  =  "contactKeith";
    $width  =  "216";
    $height  =  "23";
    break;

    case 
    clay:
    $title  =  "Clay Smith";
    $contact  =  "checked";
    $clay  =  "selected";
    $image  =  "contactClay";
    $width  =  "225";
    $height  =  "23";
    break;

    case 
    ceci:
    $title  =  "Cecilea Spencer";
    $contact  =  "checked";
    $ceci  =  "selected";
    $image  =  "contactCeci";
    $width  =  "300";
    $height  =  "23";
    break;

    case 
    lynn:
    $title  =  "Lynn Spencer";
    $contact  =  "checked";
    $lynn  =  "selected";
    $image  =  "contactLynn";
    $width  =  "261";
    $height  =  "23";
    break;

    case 
    ryan:
    $title  =  "Ryan Spencer";
    $contact  =  "checked";
    $ryan  =  "selected";
    $image  =  "contactRyan";
    $width  =  "266";
    $height  =  "23";
    break;

    case 
    grey:
    $title  =  "Grey Stephenson";
    $contact  =  "checked";
    $grey  =  "selected";
    $image  =  "contactGrey";
    $width  =  "302";
    $height  =  "23";
    break;

    case 
    sara:
    $title  =  "Sara Thurber";
    $contact  =  "checked";
    $sara  =  "selected";
    $image  =  "contactSara";
    $width  =  "249";
    $height  =  "19";
    break;
    }

    $staffEmails = array(
       
    'JohnSpencer@ccgulfbreeze.com',
       
    'SteveFeeley@ccgulfbreeze.com',
       
    'DougKimsal@ccgulfbreeze.com',
       
    'RandyPitman@ccgulfbreeze.com',
       
    'JoePrestridge@ccgulfbreeze.com',
       
    'BobRockwell@ccgulfbreeze.com',
       
    'NeilSpencer@ccgulfbreeze.com',
       
    'DaleWaltman@ccgulfbreeze.com',
       
    'BrentonCollyer@ccgulfbreeze.com',
       
    'austinbodiford@ccgulfbreeze.com',
       
    'JillBrogdon@ccgulfbreeze.com',
       
    'TerriBusey@ccgulfbreeze.com',
       
    'CDCorbin@ccgulfbreeze.com',
       
    'ChadErdwins@ccgulfbreeze.com',
       
    'CarolFeeley@ccgulfbreeze.com',
       
    'BradHarrison@ccgulfbreeze.com',
       
    'PaulKimsal@ccgulfbreeze.com',
       
    'KeithKing@ccgulfbreeze.com',
       
    'ClaySmith@ccgulfbreeze.com',
       
    'CecileaSpencer@ccgulfbreeze.com',
       
    'LynnSpencer@ccgulfbreeze.com',
       
    'RyanSpencer@ccgulfbreeze.com',
       
    'greystephenson@ccgulfbreeze.com',
       
    'SaraThurber@ccgulfbreeze.com');

    switch (
    $_POST['purpose']){
    case 
    general:
    $to  =  "information@ccgulfbreeze.com";
    break;

    case 
    staff:
    $to = isset($_POST['staff']) && array_key_exists($_POST['staff'], $staffEmails) ? $staffEmails[$_POST['staff']] : $_POST[0];
    break;

    case 
    issue:
    $to  =  "website@ccgulfbreeze.com";
    break;
    }

    $fullName $_POST['name'];
    $senderEmail $_POST['email'];
    $senderSubject $_POST['subject'];
    $senderMessage $_POST['message'];
    $subject "Website Message: {$senderSubject}";
    $body =  "This is a message from the Calvary Chapel Gulf Breeze Website."."\n".
        
    "Full Name: {$fullName}"."\n".
        
    "E-mail Address: {$senderEmail}"."\n".
        
    "Message: {$senderMessage}.";
    $headers "From: {$senderEmail}";

    mail($to$subject$body$headers);
    ?>

  5. #5
    Join Date
    Jun 2007
    Posts
    112
    I think the case statements need to be in quotes. PHP on your old server was just nice in translating them for you. Try it with quotes and see what happens.

  6. #6
    Join Date
    May 2003
    Posts
    598
    I havn't looked too deeply at the code, but it might be a security issue:
    If your host has error reporting turned off to keep possible hackers from retrieving info you may be getting the generic server error as a substitute for error reporting. Some trouble shooting steps:

    1. Set error reporting in the file:
    PHP Code:
    ini_set('error_reporting',E_ALL); 
    2. If your host gives Logging, check the logs and see what code is returned on POST
    3. Create a simple test page with only a mail function and see if that works. It will let you know if the problem is in that config.
    We do precision guesswork

  7. #7
    Join Date
    Nov 2006
    Posts
    250
    Ok, so I set the error reporting in the file like hastx suggested, so then the page actually loaded but there was a whole list of errors at the top concerning the case statements so then I did what bluestars suggested, and that got rid of all the errors concerning the switch statements. But there are still some errors, click the link below to see them.
    http://www.ccgulfbreeze.com/contact/

  8. #8
    Join Date
    Nov 2006
    Posts
    250
    I just tried a test script that included only the mail function. At first I got the 500 Internal Server Error, so then I added
    PHP Code:
    ini_set('error_reporting',E_ALL); 
    and now Im getting these errors...
    http://ccgulfbreeze.com/test.php

  9. #9
    Join Date
    Jun 2007
    Posts
    348
    "Undefined index" is normally an informational message -- which can get logged but normally doesn't prevent the page from loading. One server can have this configured differently from another. This would explain the differences you're seeing between hosts.

    To fix such an "error" instead of doing this (just an example):
    PHP Code:
    $name $_GET[name]; 
    or this:
    PHP Code:
    $name $_GET['name']; 
    Always do this, instead:
    PHP Code:
    $name '';
    if (isset(
    $_GET['name'])):
        
    $name $_GET['name'];
    endif; 
    or this:
    PHP Code:
    if (isset($_GET['name'])):
        
    $name $_GET['name'];
    else:
        
    $name '';
    endif; 
    Alternative syntax shown is my style.
    You can use braces if that is your style.
    Last edited by temp.user123; 07-04-2007 at 02:07 PM.

  10. #10
    Join Date
    Nov 2006
    Posts
    250
    Would there be a way that I can simply change the PHP configuration? So I don't have to go through and recode my script.

  11. #11
    Join Date
    May 2003
    Posts
    598
    Quote Originally Posted by novemberGrey
    Would there be a way that I can simply change the PHP configuration? So I don't have to go through and recode my script.
    Not on a paid host. their configs are usally global. Only ini variables which are allowed by script-override(such as error reporting) you have control over.

    I would just take care of the case issues and then you might be able to turn off the error reporting and be cool.

    As was mentioned earlier, "Notices" should not constitute "errors" or "warnings" and therefor your page should load ok ....even though the notices would be there, they wouldn't be seen.

    edit:
    chances are the notices were there on your old host too, you just didn't see them with how their reporting was set up. I've never seen server errors result from only notices.
    Last edited by hastx; 07-04-2007 at 02:40 PM.
    We do precision guesswork

  12. #12
    Join Date
    Nov 2006
    Posts
    250
    Ok, thankyou for your help, I've got rid of the "Undefined Index" notices but I still can't figure out how to get rid of the "Undefined Variable"

  13. #13
    Join Date
    Nov 2006
    Posts
    250
    Ugh this is getting annoying, I keep finding all these Undefined variables everywhere...there has to be something else I can do

  14. #14
    Join Date
    May 2003
    Posts
    598
    One quick way of dealing with it would be to initialize the post variables only if there was a post:

    PHP Code:

    if ($_POST){
    switch (
    $_POST['purpose']){
    case 
    general:
    $to  =  "information@ccgulfbreeze.com";
    break;

    case 
    staff:
    $to = isset($_POST['staff']) && array_key_exists($_POST['staff'], $staffEmails) ? $staffEmails[$_POST['staff']] : $_POST[0];
    break;

    case 
    issue:
    $to  =  "website@ccgulfbreeze.com";
    break;
    }

    $fullName $_POST['name'];
    $senderEmail $_POST['email'];
    $senderSubject $_POST['subject'];
    $senderMessage $_POST['message'];
    $subject "Website Message: {$senderSubject}";
    $body =  "This is a message from the Calvary Chapel Gulf Breeze Website."."\n".
        
    "Full Name: {$fullName}"."\n".
        
    "E-mail Address: {$senderEmail}"."\n".
        
    "Message: {$senderMessage}.";
    $headers "From: {$senderEmail}";

    mail($to$subject$body$headers); 

    We do precision guesswork

  15. #15
    Join Date
    Jun 2007
    Posts
    348
    Quote Originally Posted by hastx
    ... initialize the post variables only if there was a post...
    If you care:
    PHP Code:
    if ($_SERVER['REQUEST_METHOD'] == 'POST'

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles