I have the following HTML/PHP/CSS/JavaScript page:
<html>
<head>
<title>Test Guestbook</title>
<style type="text/css">
#titles {
font-family: "Comic Sans MS";
font-size: 15px;
}
#charremain {
font-family: "Comic Sans MS";
font-size: 12px;
}
.tb {
border-top: #000000 1px solid;
border-bottom: #000000 1px solid;
border-left: #000000 1px solid;
border-right: #000000 1px solid;
background-color: "#000000";
font-family: "Comic Sans MS";
resize: none;
}
.submit {
background-color: #FFCC99;
font-family: "Comic Sans MS";
}
table {
text-align: center;
width: 100%;
}
</style>
<script type="text/javascript">
function count(x){
if(x <= 100) {
document.getElementById('remain').innerHTML = 100 - x;
}
}
</script>
<script type="text/javascript">
function validate(form){
if(form.post.value == "" || form.name.value == ""){
alert("Please fill in all fields");
return false;
} else {
return true;
}
}
</script>
</head>
<body bgcolor='#FFFCC'>
<div id='titles' align='center'>
<form action='test.php' method='POST' onSubmit='return validate(this);'>
Submit a post: <br \>
<textarea id='post' class='tb' cols='25' rows='3' name='post' maxLength='100' onKeyUp="count(this.value.length)"></textarea>
<p id='charremain'>Characters Remaining: <span id='remain'>100</span></p>
Your name: <input class='tb' type='text' name='name' id='name'><br \>
<input class='submit' type='submit' value='Submit'><br \>
</form>
<br \><br \>
<H2>Current Posts:</H2>
</div>
<?php
$con = mysql_connect('localhost','root','') or die("Could not connect to localhost, check connection!");
mysql_select_db('test') or die("Could not find database");
$sql = mysql_query("SELECT * FROM `posts`");
$sqlCnt = mysql_num_rows($sql);
if($sqlCnt != 0) {
echo "<table align='center'>
<tr><td><u><H4>Message</H4></u></td>
<td><u><H4>Poster</H4></u></td></tr>";
while($row = mysql_fetch_array($sql)) {
echo "<tr><td>";
echo $row['message'];
echo "</td><td>";
echo $row['poster']
echo "</td></tr>";
}
} else {
echo "<div align='center'>Sorry, no posts found!</div>";
}
?>
</table>
</body>
Instead of proceeding to the while() loop, the webpage displays everything after , when it should be processing it. Any ideas?
Update: I added the missing semicolon, but no luck. It is an HTML file, and here is a screenshot of what I see:
http://img846.imageshack.us/img846/9867/phpx.png
Update 2:
The else section of the if() statement is working, but when the $sqlCount != 0 the code is not processed. Everything after the </tr> statement on the 3rd line of the first echo statement is echoed out, beginning with the closing parenthesis.
echo $row['poster'].<?phpin there?or dieconstruct....php?