Blog
Hey everybody....
My current project is building a blog for myself. In the process of doing this, I have come across a strange error I can't figure out. When a visitor clicks "Post a Comment" for a blog entry, it is supposed to figure out if they have a session open, and if not, have them login. You can see that at kylesview.com and click on "Post Comment"
I then get an error of an unexpected $ on line 57 of one of my includes files...but I only go until line 56...
Heres the file that its talking about:
<?php
<!-- Open Body Container -->
<div id=\"bodycontainer\">
<!-- Open Body -->
<div id=\"body\">
/* Start session */
session_start();
/* Check to find username and password */
if (!isset($_POST['username']) || !isset($_POST['password'])) {
include('/home/kview/inc/login.txt');
} elseif (isset($_POST['username']) || isset($_POST['password'])) {
/* Register session variables */
session_register('username');
session_register('password');
/* Connect to database */
$dbh = mysql_connect(\"localhost\", \"kview_kview\", \"b666log\") or die('Database failure: ' . mysql_error());
$dbh2 = mysql_select_db(\"kview_content\");
/* Grab data */
$sql = mysql_query(\"SELECT * FROM users WHERE username='$_POST[username]' AND password='$_POST[password]'\");
$qry = mysql_fetch_array($sql);
$numrows = mysql_num_rows($sql);
/* Validate */
if ($numrows != \"0\") {
/* Register variables */
$_SESSION['username'] = $qry['username'];
$_SESSION['password'] = $qry['password'];
<table>
<form method=\"post\" action=\"/php/post.php?page= echo $extra; \">
<tr><td><p class=\"heading\">Post a Comment</p></td><td></td></tr>
<tr><td><p>Title:</p></td><td><input type=\"text\" length=\"20\" maxlength=\"30\" name=\"title\" /></td></tr>
<tr><td><p>Comment:</p></td><td><textarea cols=\"40\" rows=\"25\" name=\"body\"></textarea></td></tr>
<tr><td></td><td><input type=\"submit\" value=\"Post Comment\" /></td></tr>
</table>
</form>
} else {
/* Delete sessions if not valid info */
session_unset();
session_destroy();
<p class=\"heading\">Login Failed</p>
<p>Login failed, your username and password do not match, or you don't have an account. Click <a href=\"/php/join.php\" alt=\"[Join]\">here</a> to get an account!<br />
include('/home/kview/inc/login.txt');
};
<!-- Close Body -->
</div>
<!-- Close Body Container -->
</div>
?>
That last line is line 56.
Its weird....any help would be appreciated. Thanks