Book Example Throws a 500 error
Posted: Mon Jul 11, 2016 7:04 pm
Hello everyone. Im trying to learn php so I picked up the book "Beginning php 5.3"
Right now I am using SSH to learn on a rpi2. I follow along and write the code in notepad++ on my Win10 machine. I SFTP the file over and use SSH to move the files to my /var/www/html directory. I then access the php file on my Win10 machine.
rpi2 is ...
PHP Version 5.6.22-0+deb8u1
System Linux raspberrypi 4.4.13-v7+ #894 SMP Mon Jun 13 13:13:27 BST 2016 armv7l
Build Date Jun 14 2016 17:21:33
Server API Apache 2.0 Handler
So far I got to chapter 4 without any problems. Once I got to this example I kept getting 500 errors in my browser.
What I ended up doing is commenting out sections to isolate and at the very least the first if statement is throwing one.
Does anyone have any common sense they can slap into me as to why this might happen?
Right now I am using SSH to learn on a rpi2. I follow along and write the code in notepad++ on my Win10 machine. I SFTP the file over and use SSH to move the files to my /var/www/html directory. I then access the php file on my Win10 machine.
rpi2 is ...
PHP Version 5.6.22-0+deb8u1
System Linux raspberrypi 4.4.13-v7+ #894 SMP Mon Jun 13 13:13:27 BST 2016 armv7l
Build Date Jun 14 2016 17:21:33
Server API Apache 2.0 Handler
So far I got to chapter 4 without any problems. Once I got to this example I kept getting 500 errors in my browser.
What I ended up doing is commenting out sections to isolate and at the very least the first if statement is throwing one.
Does anyone have any common sense they can slap into me as to why this might happen?
Code: Select all
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”> <html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>
<title>Greetings</title>
<link rel=”stylesheet” type=”text/css” href=”common.css” />
</head>
<body>
<?php
$hour = date( “G” );
$year = date( “Y” );
if ( $hour >= 5 && $hour < 12 )
{
echo “<h1>Good morning!</h1>”;
}
/*
elseif ( $hour >= 12 && $hour < 18 )
{
echo “<h1>Good afternoon!</h1>”;
}
elseif ( $hour >= 18 && $hour < 22 )
{
echo “<h1>Good evening!</h1>”;
}
else
{
echo “<h1>Good night!</h1>”;
}
$leapYear = false;
if ( ( ( $year % 4 == 0 ) && ( $year % 100 != 0 ) ) || ( $year % 400 == 0 ) )
$leapYear = true;
echo “<p>Did you know that $year is” . ( $leapYear ? “” : “ not” ) . “ a leap year?</p>”;
*/
?>
</body>
</html>