After migrating to the new panel PHP will not run

Are you able to copy the PHP code that isn’t working from your local file and inject it via File Manager to see if this solves the issue?

If the problem persists then paste your code here within [code] tags to see where the issue lies.

The include code in index.html is:

<?php include 'next5.php';?>

By the way, I get error 500 when I just run the next5.php on its own

The code for that is:

<?php

$db_host="localhost";
$db_user="id1540528_alfretonctc";
$db_pwd="alfretonctc";
$database="id1540528_alfretonctc";



if (!mysql_connect($db_host, $db_user, $db_pwd)) {
    die("Can't connect to database");
    }
elseif (!mysql_select_db($database)) {
    die("Can't select database");
    }


$query=("SELECT DATE_FORMAT(ridedate, '%a, %d %M %Y'), TIME_FORMAT(ridetime, '%H:%i'), place, ridetype, distance, speed, details, leader FROM calendar WHERE ridedate >= curdate() ORDER BY ridedate, ridetime, place LIMIT 5");
$result=mysql_query($query);

if (!$result) {
    die("Query to show fields from table failed");
}

$fields_num = mysql_num_fields($result);
echo "<h1>Upcoming Rides</h1>";
echo "<table id="calendar"><tr>";
  	
        echo "<th> Ride Date </th>";
        echo "<th> Start Time </th>";
        echo "<th> Meeting Place </th>";
        echo "<th> Ride Type </th>";
        echo "<th> Distance </th>";
        echo "<th> Speed </th>";
        echo "<th> Details </th>";
        echo "<th> Leader </th>";

echo "</tr>\n";
// printing table rows
$oddeven = 0;
while($row = mysql_fetch_row($result))
{
		if ($oddeven==0)		
    	{
		  echo "<tr>";
        // $row is array... foreach( .. ) puts every element    
        // of $row to $cell variable    
        foreach($row as $cell)        
       		{
       		echo "<td> $cell</td>";
       		}
        echo "</tr>\n";
        $oddeven=1;
        	
       }
        else
   		{
   		echo '<tr class="alt">';
        // $row is array... foreach( .. ) puts every element    
        // of $row to $cell variable    
        foreach($row as $cell)        
        	{
        	echo "<td> $cell</td>";
        	}
        echo "</tr>\n";
        $oddeven = 0;
        };
}
mysql_free_result($result);
?>

@cmbugg Delete .htaccess file from “public_html” .

Also downgrade your php version to 5.4 from settings – general – php version, as you’re using deprecated mysql function.

See if this solves your issue.

I already did both of those things, neither worked

Script seems to be fine, have you tried php version 5.2?

Yes, that didn’t work either

Include is not working for me on https://robtest2.000webhostapp.com/
I am not even getting any error messages I checked that the line in the .htaccess was on which it seems to be by default.

I even tried entering example 1 from w3

Hope you can help

That example is at see https://www.bitdegree.org/learn/php-include-file

Error 500 happens mostly when there are syntax errors in your PHP script.

@cmbugg @Rob-Test To show further errors details go to cPanel > Settings > General > Show errors > On

@cmbugg You used apostrophes incorrectly on line 21.

<?php

$db_host="localhost";
$db_user="id1540528_alfretonctc";
$db_pwd="alfretonctc";
$database="id1540528_alfretonctc";

if (!mysql_connect($db_host, $db_user, $db_pwd)) {
    die("Can't connect to database");
    }
elseif (!mysql_select_db($database)) {
    die("Can't select database");
    }
$query=("SELECT DATE_FORMAT(ridedate, '%a, %d %M %Y'), TIME_FORMAT(ridetime, '%H:%i'), place, ridetype, distance, speed, details, leader FROM calendar WHERE ridedate >= curdate() ORDER BY ridedate, ridetime, place LIMIT 5");
$result=mysql_query($query);
if (!$result) {
    die("Query to show fields from table failed");
}
$fields_num = mysql_num_fields($result);
echo "<h1>Upcoming Rides</h1>";
echo "<table id=\"calendar\"><tr>";
        echo "<th> Ride Date </th>";
        echo "<th> Start Time </th>";
        echo "<th> Meeting Place </th>";
        echo "<th> Ride Type </th>";
        echo "<th> Distance </th>";
        echo "<th> Speed </th>";
        echo "<th> Details </th>";
        echo "<th> Leader </th>";
echo "</tr>\n";
// printing table rows
$oddeven = 0;
while($row = mysql_fetch_row($result))
{
		if ($oddeven==0)		
    	{
		  echo "<tr>";
        // $row is array... foreach( .. ) puts every element    
        // of $row to $cell variable    
        foreach($row as $cell)        
       		{
       		echo "<td> $cell</td>";
       		}
        echo "</tr>\n";
        $oddeven=1;
       }
        else
   		{
   		echo '<tr class="alt">';
        // $row is array... foreach( .. ) puts every element    
        // of $row to $cell variable    
        foreach($row as $cell)        
        	{
        	echo "<td> $cell</td>";
        	}
        echo "</tr>\n";
        $oddeven = 0;
        };
}
mysql_free_result($result);

It defaults to on, I just cant see what I am doing wrong :frowning:

Please downgrade to PHP 5.6 (cPanel > Settings > General > Change PHP version > 5.6)

If it still doesn’t work, it is most likely an error in your PHP script. Please post your code here.

I get no response to the following:

<?php // Show all information, defaults to INFO_ALL phpinfo(); ?>

See - https://robtest2.000webhostapp.com/

You have to instruct PHP to output the result to the browser: print(phpinfo());

<?php // Show all information, defaults to INFO_ALL phpinfo(); print(phpinfo()); ?>

Still gives a blank page

Your script extension must be .php not .html.

HTML files, by default, are not parsed by PHP.


You don’t have to write phpinfo() twice. It’s useless this way.

Just leave print(phpinfo());. PHP first executes phpinfo(), then print() to output the result (from inside out) :wink:

I’ve never used Microsoft Expression for PHP files only .html

Use Notepad or Notepad++ or a PHP editor like Liquid Studio

Rather than using index.html I used index.php which seems to have solved my problems, thanks for the help.

1 Like

@cmbugg Is your issue resolved?

Yes thanks, by using index.php rather than index.html which worked on the site before migration.