I'm taking a course in Web development, learning to write PHP and I been working very hard on trying to find the errors in this script. I'm very new to programming and I get confused on where '," belong in the code.

Any suggestions you can give is very helpful. Thanks in advance.

<?php
/*Display this page
 $places = 700;
?>
<html>
<head><title>Fix this script</title>
 <style type='text/css'>
   <!--
      table {
        margin-left: 3em;
        padding: 5;
      }
      td {
           padding: .1in .25in .1in .25in;
      }

      h2,h3 {
        font-weight: bold;
        text-align: center;
      }
   -->
 </style>
</head>
<body>
<?php
$event = "Three Hundredth Annual World Magic Convention" ;
$schedule = array("Spells" => 1,"Potions" => 2,"Charms" => 3 );
define("DATE","January 15");

echo "<h2>"style="color: red Announcing the $event"</h2>";
echo "<h3>".DATE."</h3>";
echo "<p>This yearly conference—the premier education and networking forum for the magic community—is the place"; 
echo "to learn about the most successful magic methodologies and to understand how to integrate new magic technologies into your current practices. </p>";

echo '<p>This year's conference offers the following educational events.</p>';

echo "<table border='1'>"
      <tr><th>Time</th><th>Session</td></tr>";
foreach($schedule as $name => $time)
{
   echo "<tr>
         <td>$time</td>
		 <td>$name</td>
		 </tr>";
}
echo "</table>;
echo "<p style='margin-top: 2em'>Witches and Warlocks! Hurry and sign up! Places are filling up fast. ";
echo '<h3>Only $places places left</h3>'; 
    

?>
</body>
</html>

The problem you are having is with your double quotes.

echo "value of the constant CONSTANT: " . CONSTANT;

notice the text in blue, this is a string. You are trying to put double quotes inside a string without escaping them. If you place a backslash directly before a double quote php will take it as a part of the string instead of the string termination:

//like this:
echo "value of the constant \"CONSTANT\": " . CONSTANT;
//not this:
echo "value of the constant "CONSTANT": " . CONSTANT;

Also, I don't think it is possible to put a string over multiple lines how you are. You should put them on one line and use '\n' (no quotes) to echo a new-line character.

It was really buggy but I think I found all the bugs. Below is the corrected code.

<?php
//Display this page
$places = 700;
?>
<html>
<head><title>Fix this script</title>
<style type='text/css'>
<!--
table {
margin-left: 3em;
padding: 5;
}
td {
padding: .1in .25in .1in .25in;
}

h2,h3 {
font-weight: bold;
text-align: center;
}
-->
</style>
</head>
<body>
<?php
$event = 'Three Hundredth Annual World Magic Convention' ;
$schedule = array('Spells' => 1,'Potions' => 2,'Charms' => 3 );
define('DATE','January 15');

echo "<h2>\"style=\"color: red Announcing the $event\"</h2>";
echo '<h3>'.DATE.'</h3>';
echo '<p>This yearly conference—the premier education and networking forum for the magic community—is the place'; 
echo 'to learn about the most successful magic methodologies and to understand how to integrate new magic technologies into your current practices. </p>';

echo '<p>This year\'s conference offers the following educational events.</p>';

echo '<table border="1">
<tr><th>Time</th><th>Session</td></tr>';
foreach($schedule as $name => $time)
{
echo "<tr>
<td>$time</td>
<td>$name</td>
</tr>";
}
echo '</table>';
echo '<p style=\'margin-top: 2em\'>Witches and Warlocks! Hurry and sign up! Places are filling up fast. ';
echo '<h3>Only $places places left</h3>'; 
?>
</body>
</html>
This article has been dead for over six months. Start a new discussion instead.