Jump to content

PHP version issue?


lee_sov

Recommended Posts

Hi, we've recently moved a website to a different host & now have a problem with the contact us php page. this was all working fine on the previous host & the files have been directly copied to the new host so nothing has changed.

 

The html part of the site is all fine but when trying to browse to the contact us php page, we receive:

 

500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed.

​The only difference, from what I can see is the PHP version, - on the old host it was 5.3.28 & the new host is 5.2 & cannot be changed. Would that cause this issue, or is this something else altogether?

 

Thanks

Link to comment
Share on other sites

I know I was just as surprised when they told us! We have many of our clients at the same host (123-Reg) & due to issues with the previous host we moved this one as well, just haven't had any php issues before! this is on a shared windows hosting platform & they say 5.2 is the highest version available!

 

Would that be the reason then for receiving this error, & is there any way around it?

Link to comment
Share on other sites

Current code is here:

<?php
ini_set('display_errors', 1); 
$SENT = false;
if ($_POST && $_POST["name"] && preg_match("/^[a-zA-Z0-9 ]+$/i", $_POST["name"]) !== false && $_POST["email"] && preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $_POST["email"]) !== false) { 
 
try {
  include_once('class.phpmailer.php');
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->Host = "smtp.gmail.com"; // place your smtp host here
    $mail->SMTPAuth = true;
    $mail->SMTPSecure = "ssl";
    $mail->Username = "mail@emailaddress.com "; // place your smtp username here
    $mail->Password = "Password"// place your smtp password here
    $mail->Port = "465";
 
    $mail->From = $_POST["email"];
    $mail->FromName = $_POST["name"];
    $mail->AddAddress("mail@emailaddress.com ");
 
    $mail->Subject = "Enquiry from the  Website";
 

 // build the email
 $s = "The following contact form has been submitted:\n\n";
 
 $s .= "=== Customer Details =====\n";
 $s .= "Name: " .$_POST["name"]. "\n";
 $s .= "Company: " .$_POST["company"]. "\n";
 $s .= "Telephone: " .$_POST["telephone"]. "\n";
 $s .= "Email Address: " .$_POST["email"]. "\n\n";
 
 $s .= "=== Enquiry Information =====\n";
 $s .= trim($_POST["comments"])."\n\n";
 
 $s.= "Generated: " .date("Y-m-d H:i:s");
 
 $mail->Body = $s;
 $mail->WordWrap = 72; // wrap text to 72 characters
 

 //  echo "Attempting to send e-mail...";
 if ($mail->Send()) {
  $SENT = true;
 // echo "Success!";
 } else {
  $SENT = false;
 //  echo "Failed!";
 }
} catch (phpmailerException $e) {
    echo $e->errorMessage();
  } catch (Exception $e) {
    echo $e->errorMessage();
  } 
}
 
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
 
<head>
 <title></title>
 <meta name="keywords" content="" />
 <meta name="description" content="" />
 <meta http-equiv="imagetoolbar" content="no" />
 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
 <meta name="revisit-after" content="7 days">
 <meta name="Copyright" content="">
 <meta name="Robots" content="all">
 <meta name="language" content="en">
 <meta name="distribution" content="Global">
 
 <link rel="shortcut icon" href="/favicon.ico" />
 <link rel="stylesheet" type="text/css" href="css/print.css" media="print" />
 
 <style type="text/css" media="screen">
 <!--
 @import url(css/styles.css);
 -->
 </style>
 <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true"></script>
 <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=en"></script>
 <script src="js/jquery-1.5.1.min.js" type="text/javascript"></script>
  <script src="js/global.js" type="text/javascript"></script>
 <script src="js/jquery.goomaps.js" type="text/javascript"></script>
 
 
</head>
 
<body>
 
<div id="container_header">
 <div id="header">
 
 <div id="logo"><h1><a href="/" title="Home"><span></span></a></h1></div>
 
 
    </ul>
   </li>
 
  <li><a href="contact.php" class="active">Contact Us</a></li>
  </ul>
 </div>
 
 </div>
</div>
 
<div id="container_body">
 <div id="body">
  
  <div class="clearboth"> </div>
 

  <div id="home_panel">
 
   <div id="home_bottompanel_content">
 
   <h2>Contact Us</h2>
  
   <div class="goomapsWrapper">
    <h3> Office</h3>
    <p>
   >
     <br />
     <span>T:</span> +44 0<br />
     <span>F:</span> +44 <br />
     <span>DX:</span> <br />
     <span>E:</span> <a href="mailto:mail@emailaddress.com">mail@emailaddress.com</a>
     
    </p> 
    <div id="map_canvas" class="map_canvas"></div> 
   </div>
   <div class="goomapsWrapper">
    <h3> Office</h3>
    <p>
     
     <br />
     <span>T:</span> +44 <br />
     <span>F:</span> +44 <br />
     <span>DX:</span> <br />
     <span>E:</span> <a href="mailto:mail@emailaddress.com">mail@emailaddress.com</a>
    </p>     
    <div id="map_canvas2" class="map_canvas"></div>     
   </div>   
 
   <div>

   <?php if (!$SENT) { ?>
 
   <?php if (!$SENT && $_POST) {
    echo '<p class="red">There was a problem with sending the form.<br />Please check to ensure you have filled in all the fields.</p>';
   } ?>
   <p><b>Enquiry Form</b><br />
   <span class="red">**</span> Indicates required fields</p>
   
   <script src="https://www.google.com/recaptcha/api.js" async defer></script>
   <form name="contact" action="contact.php" method="post">
   <fieldset class="conform">
   <legend>Your Details</legend><br />
   <label for="name">Name</label>
   <input id="name" type="text" size="40" value="<?php echo (isset($_POST["name"])) ? $_POST["name"] : '' ; ?>" name="name" /> <span class="red">**</span><br />
   <label for="company">Company</label>
   <input id="company" type="text" size="40" value="<?php  echo (isset($_POST["company"])) ? $_POST["company"] : '' ; ?>" name="company" /><br />
   <label for="telephone">Telephone</label>
   <input id="telephone" type="text" size="40" value="<?php echo  (isset($_POST["telephone"])) ? $_POST["telephone"] : ''; ?>" name="telephone" /><br />
   <label for="email">Email Address</label>
   <input id="email" type="text" size="40" value="<?php echo (isset($_POST["email"])) ? $_POST["email"] : ''; ?>" name="email" /> <span class="red">**</span><br />
   </fieldset>
 
   <fieldset class="conform2">
 
   <legend>Further Information</legend><br />
   <textarea id="comments" name="comments" size="40" rows="8" cols="50"><?php  echo(isset($_POST["comments"])) ? $_POST["comments"] : '' ; ?></textarea>
   </fieldset>
   <html>
 
     <div class="g-recaptcha" data-sitekey="My Site Key"></div><br>
 
   <br />
   <a href="javascript:document.contact.submit();"><img title="" height="43" alt="" src="images/submit.gif" width="102" border="0" /></a>
   </form>
   </div>
 
   <?php
    } else {
   ?>
   <p>Thank you for your enquiry. We will reply as soon as possible.</p>
   <?php
    }
   ?>
 
  </p>
 

   </div>
 
  </div>

  
 </div>
 
  <script>
   $(document).ready(function(){
   $('#map_canvas').goomaps("init", {
   center: [51.467434,0.008308],
   zoom: 16,
    clickable: true,
    draggable: true,
    scrollwheel: false,
   OverviewMapControlOptions: false,
   }).goomaps("addmarkers", [{ options: {
    position: [51.467434,0.008308]
 
    
    
   }}]);
   $('#map_canvas2').goomaps("init", {
   center: [51.462998,-0.010772],
   zoom: 16,
    clickable: true,
    draggable: true,
    scrollwheel: false,
   OverviewMapControlOptions: false,
   }).goomaps("addmarkers", [{ options: {
    position: [51.462998,-0.010772]
 
    
   }}]);  
   });
  </script>
 
</body>
</html>
Edited by requinix
fixing code so it doesn't break highlighting
Link to comment
Share on other sites

You have numerous problems with that code.

 

You are missing a quote here: $mail->Password = "Password"// place your smtp password here   

 

 

 

Your html is all over the place incorrectly. You have two html start tags. You have several closing tags with no opening tags.

 

 

more coming.....

Edited by benanamen
Link to comment
Share on other sites

PHP 5.2 reached end of life back in 2011 and hasn't received any security updates ever since. Running this on a public webserver is just reckless and unprofessional.

 

Get a hoster which actually cares about the servers and keeps them up-to-date. The currently supported PHP versions are 5.6 and 7.

  • Like 1
Link to comment
Share on other sites

Have you tried removing all the PHP code at the top and then adding it back a little at a time? This should help you track down the offending code.

 

I've tried taking all the php code out at the top & I still receive the 500 Internal server error so it must be something to do with the page itself, - being saved as a *.php or that the server doesn't like it maybe?

 

As a test, I created a blank page with nothing in it, saved it as test.php & uploaded it. As soon as I try to browse to that page I receive the same error so it must be something to do with the php file extension. As soon as I changed the file name to test.html, it worked fine...

Edited by lee_sov
Link to comment
Share on other sites

the code you posted in this thread was broken because you made edits to it to remove information from the post and you removed at least one quote/semi-colon, which made it next to impossible to help based on the code, because we don't know what else you may have changed in it when posting it.

 

repost the code, literally just replacing any sensitive information with x's (you should have this type of information defined in a require'ed file using variables or defined constants anyway), but do not modify any syntax, such as quotes, semi-colons, ...

 

next, assuming this is a run-time error, and not a php syntax error, you should have the following three lines at the start of your php code to get all php detected run-time errors reported and displayed - 

ini_set("display_startup_errors", "1");
ini_set("display_errors", "1");
error_reporting(-1);

have you tried a .php file with just something simple like the following in it - 

<?php
echo 'yes php works';
?>

is there a .htaccess file that came from the old hosting? it may have some statements in it that's producing an error. however, there should be errors in the web server error log. if you do have a .htaccess file, what is the contents of the .htaccess file?

 

also, what was the web server type on the both the old and new hosting?

Edited by mac_gyver
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.