Ok, I got that string problem done, but now I have a problem with my SQL code. Here's the code for "journal.php":
Link:http://www.noenemies.com/journal.php
For some reason, when I try to post a comment, it doesn't insert it into the database. I know I'm connected to the right database, because the journal entry is pulled from the database. I've doublechecked all variable names, so I'm pretty sure it's not that.
Any ideas?
<?php include_once('header.html'); if (isset($_REQUEST['view'])) { $p_id = $_REQUEST['view']; } else { $p_id = ''; } ?> <div id="content"> <?php if ($p_id = $_REQUEST['view']){ if(isset($_POST['submit'])) { $n = $_POST['name']; $c = $_POST['comment']; $query = "INSERT INTO journalComment (name, comment, date, journalid) VALUES ('$n', '$c', NOW(), '$p_id')"; $result = @mysql_query($query); } $query = "SELECT title, content, DATE_FORMAT(date, '%M %d, %Y') AS date FROM journal WHERE id = $p_id"; $result = @mysql_query($query); $row = @mysql_fetch_array($result, MYSQL_ASSOC); echo '<h1>'; echo $row['title']; echo '</h1>'; echo '<p><b>[ '; echo $row['date']; echo ' ] </b></p><p>'; echo $row['content']; echo '</p>'; $query = "SELECT id, name, comment, DATE_FORMAT(date, '%M %d, %Y') AS date FROM journalComment WHERE journalid = $p_id ORDER BY id DESC"; $result = @mysql_query($query); echo '<h1>Comments</h1>'; while($row = @mysql_fetch_array($result, MYSQL_ASSOC)) { echo '<p><i>'; echo $row['date']; echo '</i> - <b>'; echo $row['name']; echo '</b></p><p>'; echo $row['comment']; echo '</p>'; } $commentidrightnow = $_REQUEST['view']; echo '<form action="journal.php?view="'; echo $commentrightnow; echo '" method="post">'; echo '<h2>Add a Comment</h2>'; echo '<p><b>Name</b><br><input type="text" name="name" size="25"></p>'; echo '<p><b>Comment</b><br><textarea rows="8" cols="20"></textarea></p>'; echo '<input type="submit" name="submit" value="Post">'; echo '</form>'; } else { $query = "SELECT id, title, content, DATE_FORMAT(date, '%M %d, %Y') AS date FROM journal ORDER BY id DESC"; $result = mysql_query($query); $first = TRUE; $num = 0; while ($row = @mysql_fetch_array($result, MYSQL_ASSOC)) { $num = $num + 1; echo '<h1>'; echo $row['title']; echo '</h1>'; echo '<p><b>[ '; echo $row['date']; echo ' ] </b></p><p>'; $content = substr($row['content'],0,200); echo $content; echo '...'; echo '<b><a href="journal.php?view='; echo $row['id']; echo '">Read More</a></b></p>'; $first = FALSE; } if ($first) { echo 'Nothing here.'; } } ?> </div> <?php include_once('footer.html'); ?>
Link:http://www.noenemies.com/journal.php
For some reason, when I try to post a comment, it doesn't insert it into the database. I know I'm connected to the right database, because the journal entry is pulled from the database. I've doublechecked all variable names, so I'm pretty sure it's not that.
Any ideas?