Home › Forums › Scripts › GirlsWhoGeek Scripts › Build A Blog " LEAVE A COMMENT " problem :S
Tagged: build-a-blog
This topic contains 7 replies, has 6 voices, and was last updated by Kitty 1 year, 11 months ago.
-
AuthorPosts
-
April 15, 2011 at 4:23 am #13845
Hi everyone

Well , I have follow the tutorial for the Build A Blog script , and everything is perfect , except one thing , when we go on the index.php , when we click on ” Leave a comment ” I got this :
Invalid ID specified.
And the url don’t show the ID of the entry.
Well , I want some help to fix this

Here’s the url ( it’s a demo url , it’s just or testing everything before ) : http://oasis-designs.net/newblog/
Thank you very much for your help

Myranie
xoxo
April 15, 2011 at 1:39 pm #14467The post IDs are not currently being passed to the Leave a Comment link – if you look at the html it looks like this: your-url/newblog/entry.php?id=
April 15, 2011 at 5:46 pm #14468Can you post the code you’re using for index.php? (Remove any passwords)
April 15, 2011 at 6:33 pm #14469Here’s the code :
<?php
mysql_connect ('localhost', 'mymy_blog', '') ;
mysql_select_db ('mymy_blog');
$sql = "SELECT * FROM php_blog ORDER BY timestamp DESC LIMIT 5";
$result = mysql_query($sql) or print ("Can't select entries from table php_blog." . $sql . "" . mysql_error());
while($row = mysql_fetch_array($result)) {
$date = date("l F d Y", $row['timestamp']);
$title = stripslashes($row['title']);
$entry = stripslashes($row['entry']);
?>
<p><strong><?php echo $title; ?></strong>
<?php echo $entry; ?>
<?php
$result2 = mysql_query ("SELECT id FROM php_blog_comments WHERE entry='$id'");
$num_rows = mysql_num_rows($result2);
if ($num_rows > 0) {
echo "<a href="entry.php?id=">" . $num_rows . " comments</a>";
}
else {
echo "<a href="entry.php?id=">Leave a comment</a>";
} ?>
<hr /></p>
<?php
}
?>April 15, 2011 at 6:41 pm #14470The part where you echo Leave a comment is interpreted as HTML, and I see it like:
echo "<a href="entry.php?id=">Leave a comment</a>";It should be something like:
echo "<a href="entry.php?id=$id">Leave a comment</a>";Incidentally, I don’t see you initialize the $id variable anywhere. In which case its value is NULL so it wouldn’t show up in the HTML link’s src (hence your problem).
Instead of just:
$title = stripslashes($row['title']);
$entry = stripslashes($row['entry']);have:
$title = stripslashes($row['title']);
$entry = stripslashes($row['entry']);
$id = $row['id'];April 15, 2011 at 7:21 pm #14471Yeah
It’s working …. thank you so much for your help
June 14, 2011 at 3:24 am #14472Hey!
Let me start off by saying thank you sooo much for your Build a Blog tutorial. You guys are amazing but I had a little bit of a hard time following the commenting process.
So! here goes:
I’m also having a ‘leave a comment’ problem but pretty sure it’s not the same thing that Myranie was having.
heres a really crappy start at my blog:
I click ‘leave a comment’ and it just stays there. I know I must be missing something huge but I just don’t know!!!
June 14, 2011 at 12:50 pm #14473What do you mean ‘it just stays there’? Moreover, when I click the Leave a comment button, it takes me to the edit comment page, not the comment page itself.
-
AuthorPosts
You must be logged in to reply to this topic.



Recent Comments