Solved

500 Internal Server Error within Wordpress

Posted on 2014-02-10
14
2,001 Views
Last Modified: 2014-02-11
I have just moved the website in the below link to a new server:

http://46.32.231.136/~themarbl/get-a-free-quote/

The form on the above link should load content from a mysql database.

If you look on the console on this page you see this error:

Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://46.32.231.136/~themarbl/wp-content/themes/dt_delicate/ajax.php

The ajax.php file does exist. Any idea why I would be getting this error?

This is the original working url if you want to compare: http://www.themarblegroup.co.uk/get-a-free-quote/
0
Comment
Question by:petewinter
  • 6
  • 4
  • 3
  • +1
14 Comments
 
LVL 19

Assisted Solution

by:Patricksr1972
Patricksr1972 earned 67 total points
ID: 39848544
Sounds like the server/service running the website on the new server cannot reach the sql server. Can you connect to it manually from the new server?
0
 
LVL 58

Assisted Solution

by:Gary
Gary earned 67 total points
ID: 39848556
500 isn't a Not Found error, its a server error i.e. your code is erroring out.
0
 

Author Comment

by:petewinter
ID: 39848569
Thanks, but even if I can the ajax.php file code to simply...

<?php echo "hello"; ?>

I still get the same error?
0
 

Author Comment

by:petewinter
ID: 39848581
I meant...

Thanks, but even if I change the ajax.php file code to simply...

<?php echo "hello"; ?>

I still get the same error?
0
 
LVL 58

Expert Comment

by:Gary
ID: 39848590
Are you sure you are editing the right file
/~themarbl/wp-content/themes/dt_delicate/ajax.php
0
 
LVL 58

Expert Comment

by:Gary
ID: 39848605
Actually your main page is returning a 500 error code even though it is loading.
0
 
LVL 34

Accepted Solution

by:
Dan Craciun earned 366 total points
ID: 39848609
Are you, by any chance, running suPHP on your server?

If so, you need to have all files 644 and all your folders 755, or you'll get 500 errors on all your php pages.

Even if you're not running suPHP you might want to check permissions on that file. Wordpress can be very picky on file permissions on the server.

HTH,
Dan
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:petewinter
ID: 39848621
Yes. I just tried something else...

Two very basic files with the same code below, but different file extensions...

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
</head>

<body>
test
</body>
</html>

Open in new window


HTML: http://46.32.231.136/~themarbl/wp-content/themes/dt_delicate/test.html

PHP: http://46.32.231.136/~themarbl/wp-content/themes/dt_delicate/test.php

Why does the php file give an error?
0
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39848626
Can you post a phpinfo() and the permissions on the test.php file?
0
 
LVL 58

Expert Comment

by:Gary
ID: 39848633
The php file works fine.
Try disabling all your plugins, it's possible one them is evaluating some code causing the error
0
 
LVL 34

Assisted Solution

by:Dan Craciun
Dan Craciun earned 366 total points
ID: 39848634
Also, do you have a htaccess file? Check the rules if you do (or temporarily delete it and see if it makes any difference)
0
 

Author Comment

by:petewinter
ID: 39848638
Thanks the permission solved the folder test.php file issue. Now just looking into the database connection.
0
 

Author Comment

by:petewinter
ID: 39848667
This is the code for the ajax.php file:

<?php

require_once ("marblestore_db.php");

//require_once ("ini.php");

//$_db = new mySqldb ( _DBHOST, _DBUSER, _DBPASS, _DBNAME ); //mySQl DB Instance for Sims DB





$content = '';

if(isset($_REQUEST['action'])){

 //open the data base

 $ms_db = new mysqli(MARBLESTORE_DBHOST, MARBLESTORE_DBUSER, MARBLESTORE_DBPASS, MARBLESTORE_DBNAME);

 if ($ms_db->connect_error) {

    die('Connect Error (' . $ms_db->connect_errno . ') '

            . $ms_db->connect_error);

 }

 switch($_REQUEST['action']){

 case 'send_email':

  //first check the captcha

  $captcha_prefix =$_REQUEST['captcha_prefix'];

  $captcha_value = strtoupper($_REQUEST['captcha_value']);

  $captcha_img=dirname(dirname(dirname(__FILE__)))."/plugins/really-simple-captcha/tmp/$captcha_prefix.png";

  $file=dirname(dirname(dirname(__FILE__)))."/plugins/really-simple-captcha/tmp/$captcha_prefix.txt";

  if ( is_readable( $file ) && ( $code = file_get_contents( $file ) ) ) {

   $code = explode( '|', $code, 2 );

   $salt = $code[0];

   $hash = $code[1];

   if ( hash_hmac( 'md5', $captcha_value, $salt ) !== $hash ){

    $data="Incorrect security code";

    $content=json_encode($data);

    break;

   }

  } else {

   $data="Unknown error";

   $content=json_encode($data);

   break;

  }

  // $data="Incorrect security code ".$_REQUEST['captcha_prefix']." ".$_REQUEST['captcha_value'];



  $to      = $_REQUEST['email'];

  $name    = $_REQUEST['name'];

  $phone   = $_REQUEST['phone'];

  $brand   = $_REQUEST['brand'];

  $location = $_REQUEST['address'];

  $info     = $_REQUEST['info'];

  $thickness = $_REQUEST['thickness'];

  $product = $_REQUEST['product'];

  $style   = $_REQUEST['style'];

  $sink    = $_REQUEST['sink'];

  $grooves = $_REQUEST['grooves'];

  $hob     = $_REQUEST['hob'];

  $tab     = $_REQUEST['tab'];

  $plug    = $_REQUEST['plug'];

  $fitting = $_REQUEST['fitting'];

  $templating= $_REQUEST['templating'];

  $price    = $_REQUEST['price'];

  $vat    = $_REQUEST['vat'];

  $total    = $_REQUEST['total'];

  $subject = 'Quote Requested via themarblegroup.co.uk';

  $message = "Quote Requested 

Customer: $name

Email:$to

Telephone: $phone

Location: $location

   

Quote Requested $product ($brand) $thickness for following items and services:



Worktop pieces sizes:\r\n";

for($i=0;$i<count($_REQUEST['wtl']);$i++)

 $message.="  ".$_REQUEST['wtl'][$i]." [mm] x ".$_REQUEST['wtr'][$i]." [mm] \r\n";

$message.="Upstands/Splashback pieces sizes:";

if(count($_REQUEST['usl'])==0)

 $message.= " 0\r\n";

else

 $message.= " \r\n";

for($i=0;$i<count($_REQUEST['usl']);$i++)

 $message.= "  ".$_REQUEST['usl'][$i]." [mm] x ".$_REQUEST['usr'][$i]." [mm] \r\n";

$message.="Number of cout-outs of $style sink: $sink \r\n";

$message.="Number of sets of drainer grooves: $grooves \r\n";

$message.="Number of cut-outs for a hob: $hob \r\n";

$message.="Number of tab holes: $tab \r\n";

$message.="Number of plug holes: $plug \r\n\r\n";

if($fitting==1)

 $message.="Fitting: [YES] \r\n";

else

 $message.="Fitting: [NO] \r\n";

if($templating==1)

 $message.="Templating [YES]\r\n";

else

 $message.="Templating [NO]\r\n";

if($info!='')

 $message.="User Message:\r\n $info \r\n";

$message.="\r\n Price Ex VAT: $price GBP \r\n";

$message.=" VAT: $vat GBP \r\n";

$message.=" Total Price: $total GBP \r\n";

$headers = 'From: info@themarblegroup.co.uk' . "\r\n" .

    'Cc: info@themarblegroup.co.uk' . "\r\n";

    'Reply-To: info@themarblegroup.co.uk' . "\r\n" .

    'X-Mailer: PHP/' . phpversion();

  if(mail($to, $subject, $message, $headers))

   $data='Your quote was sent';

  else

   $data='Error, try again';

  $content=json_encode($data);

  break;

 case 'brandnames':

  $result=$ms_db->query("select id,value from areas where areaname='brandname' order by value");

  while($row = $result->fetch_assoc())

   $content.='<option class="marble_selected_brand" value='.$row['id'].'>'.$row['value'].'</option>';

  break;

 case 'products':

  if(isset($_REQUEST['brand'])){

   $var=$ms_db->real_escape_string('-'.$_REQUEST['brand'].'-');

   $result=$ms_db->query("select id,name from product where brand like '$var' order by name");

   $selected=false;

   while($row = $result->fetch_assoc())

    if(!$selected){

     $content.='<option selected class="marble_selected_product" value='.$row['id'].'>'.$row['name'].'</option>';

     $selected=true;

    } 

    else

     $content.='<option class="marble_selected_product" value='.$row['id'].'>'.$row['name'].'</option>';

  }

  break;

 case 'prices':

  if(isset($_REQUEST['id'])&&isset($_REQUEST['thickness'])&&isset($_REQUEST['style'])){

   $id=$ms_db->real_escape_string($_REQUEST['id']);

   $thickness=$ms_db->real_escape_string($_REQUEST['thickness']);

   $style=$ms_db->real_escape_string($_REQUEST['style']);

   // query price

   $result=$ms_db->query("select price from price where pricegroup='$id' AND thickness='$thickness'");

   $out = $result->fetch_assoc();

   $data['price']=$out['price'];

   // query unit prices

   $queries['splashback']=1;

   $queries['style']=$style;

   $queries['grooves']=31;

   $queries['hob']=4;

   $queries['tab']=5;

   $queries['plug']=25;

   $queries['fitting']=7;

   $queries['templating']=6;

   

   $queries['polishedsink']=2;   

   $queries['angles']=29;

   $queries['curves']=30;

   $queries['hobbar']=28;

   $queries['hobcutout']=26;

   $queries['recesseddrainer']=32;

   $queries['choppingboard']=27;

   $queries['worktopcleaning']=33;

   

   $queries['dblpencil']=11;

   $queries['singlepencil']=12;

   $queries['dblchamfer']=13;

   $queries['singlechamfer']=14;

   $queries['cove']=10;

   $queries['halfbullnose']=19;

   $queries['a20birdsbak']=16;

   $queries['a20flat']=17;

   $queries['irishwaterfall']=18;

   $queries['mitrededge']=15;

   $queries['ogee']=22;

   $queries['fullbullnose']=23;

   $queries['dupontedge']=24;

   $queries['ogee20bullnose']=21;

   $queries['ogee30bullnose']=20;

   

   foreach($queries as $key=>$value){

    $result=$ms_db->query("select unitprice from service where id='$value'");

    $out = $result->fetch_assoc();

    $data[$key]=$out['unitprice'];

   }

   // query mandatory service

   $queries=array();

   $queries['fitting']=7;

   $queries['templating']=6;

   $queries['vat']=8;

   foreach($queries as $key=>$value){

    $result=$ms_db->query("select price from mandatory_service where id='$value'");

    $out = $result->fetch_assoc();

    $data[$key]=$out['price'];

   }

   $content=json_encode($data);

  }

  break;

 case 'product':

  if(isset($_REQUEST['id'])){

   $var=$ms_db->real_escape_string($_REQUEST['id']);

   $result=$ms_db->query("select id,price,thicknesses,finishings,image from product where id='$var'");

   $row = $result->fetch_assoc();

   $data['id']=$row['id'];

   $data['price']=$row['price'];

   $data['image']=$row['image'];

   //get names for thickness

   $thicknesses=explode('-',$row['thicknesses']);

   foreach($thicknesses as $thickness)

    if($thickness!=''){

     $data['thickness_id'][]=$thickness;

     $result=$ms_db->query("select value from areas where id='$thickness'");

     if($out = $result->fetch_assoc())

     	$data['thickness_value'][]=$out['value'];

    }

   $finishings=explode('-',$row['finishings']);

   foreach($finishings as $finishing)

    if($finishing!=''){

     $data['finishing_id'][]=$finishing;

     $result=$ms_db->query("select value from areas where id='$finishing'");

     $out = $result->fetch_assoc();

     $data['finishing_value'][]=$out['value'];

    }

   $content=json_encode($data);

  }

  break;

}

 $ms_db->close();

}

echo $content;

?>

Open in new window


and this is the marblestore_db.php file with the database details removed...

<?php

/**

 * database settings 

 *

 */

 //ini_set('display_errors','On');

//error_reporting(E_ALL);



define ( "MARBLESTORE_DBHOST", "localhost" );

define ( "MARBLESTORE_DBUSER", "xxx" );

define ( "MARBLESTORE_DBPASS", "xxx" );

define ( "MARBLESTORE_DBNAME", "xxx" );

Open in new window


I also tested the data base with the code below and it was fine.

$server   = "localhost";
$database = "xxx";
$username = "xxx";
$password = "xxx";

$mysqlConnection = mysql_connect($server, $username, $password);
if (!$mysqlConnection)
{
  echo "Please try later.";
}
else
{
mysql_select_db($database, $mysqlConnection);
echo "it works";
}

Open in new window


Any idea what I am not seeing the data on the page below?

http://46.32.231.136/~themarbl/get-a-free-quote/
0
 

Author Closing Comment

by:petewinter
ID: 39849509
Thanks for your help with the permissions. The issue with the database connect was that I needed to install MySQLi.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
This article discusses four methods for overlaying images in a container on a web page
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now