I’m designing a fairly simple reporting system. Right now using php(and later some Jquery) to let user log in and calculate totals and post to a database. My problems began of course when I tested the page in IE8. It has major problems with the echo <<<_END statement at line 75. Anyone know an alternate to coding the nested HTML in the PHP besides this. any help is appreciated.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<link rel="stylesheet" type="text/css" href="OPSstyle.css" />
</HEAD>
<BODY>
<div id="wrapper">
<div id="bodyContent">
<div id="header">
<img id="logo" src="OPS_logo.gif" alt="OPS Logo"/>
<p>OPS ASSESSMENT</p>
</div>
<div id="leftNav">
<p>To begin please login</p>
<a href="loginusers.php">Test Login</a><br/>
<a href="sqltest.php">Form Test</a><br/>
</div>
<div id="content">
<?php
//Connects to database
require_once 'login.php';
$db_server = mysql_connect($db_hostname, $db_username, $db_password);
if(!$db_server) die("Unable to connect to MySQL: " .mysql_error());
mysql_select_db($db_database)
or die ("unable to select database: " .mysql_error());
//deletes record
if(isset($_POST['delete']) && isset($_POST['AssessmentID']))
{
$AssessmentID = get_post('AssessmentID');
$query2 = "DELETE FROM assessmentscores WHERE AssessmentID='$AssessmentID'";
if(!mysql_query($query2, $db_server))
echo "Delete Failed: $query(br />" .
mysql_error() . "<br /><br />";
}
//Inserts record
if (isset ($_POST['AssessmentID'])&&
isset($_POST['Date']) &&
isset($_POST['Inspector']) &&
isset($_POST['PlantAssist']) &&
isset($_POST['Safety_Total'])
)
{
$AssessmentID = get_post('AssessmentID');
$Date = get_post('Date');
$Inspector = get_post('Inspector');
$PlantAssist =get_post('PlantAssist');
$Safety_Total = get_post('Safety_Total');
;
$query = "INSERT INTO opsassessment.assessmentscores(AssessmentID, Date, Inspector, PlantAssist, `Safety_Total`) VALUES" .
"('$AssessmentID', '$Date', '$Inspector', '$PlantAssist', '$Safety_Total')";
if (!mysql_query($query, $db_server))
echo "INSERT failed: $query<br />" .
mysql_error() . "<br /><br />";
}
echo <<<_END
<form action = "sqltest.php" method="post"><pre>
AssessmentID <input type="text" name="AssessmentID" /><br>
Date <input type="text" name="Date" /><br>
Inspector <input type="text" name="Inspector" /><br>
PlantAssist <input type="text" name="PlantAssist" /><br>
Safety_Total <input type="text" name="Safety_Total" /><br>
<input type="submit" value="ADD RECORD" /><br>
</pre></form>
_END;
$query = "SELECT * FROM assessmentscores";
$result = mysql_query($query);
if (!$result) die("Database access failed: " .mysql_error());
$rows = mysql_num_rows($result);
for($j = 0; $j < $rows; ++$j)
{
$row= mysql_fetch_row($result);
echo <<<_END
<pre>
AssessmentID: $row[0]
Date: $row[1]
Inspector: $row[2]
PlantAssist: $row[3]
Safety_Total: $row[4]
</pre>
<form action="sqltest.php" method="post">
<input type ="hidden" name="delete" value ="yes" />
<input type = "hidden" name="AssessmentID" value = "$row[0]" />
<input type ="submit" value="DELETE RECORD" /></form>
_END;
}
mysql_close($db_server);
function get_post($var)
{
return mysql_real_escape_string($_POST[$var]);
}
?>
</div>
<a href="form1.php">Login Form</a><br><br>
<a href="testOPS.php">OPS Assessment</a>
</div>
</body>
</html>
The Heredoc identifier must on a line of itself and must be the only thing on this line (including indentation and such). Remove the leading whitespace and make sure the newline is direct after
_END;.However, in your case I suggest you to just leave the PHP-mode to output the plain html
For example instead of
this
Its usually more readable and many IDEs are capable to recognize it and highlight the “other stuff” as html.