Build A Blog " LEAVE A COMMENT " problem :S

Home Forums Scripts GirlsWhoGeek Scripts Build A Blog " LEAVE A COMMENT " problem :S

Tagged: 

This topic contains 7 replies, has 6 voices, and was last updated by  Kitty 1 year, 11 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #13845

    myranie
    Participant

    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

    #14467

    Jem
    Keymaster

    The 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=

    #14468

    Amelie
    Keymaster

    Can you post the code you’re using for index.php? (Remove any passwords)

    #14469

    myranie
    Participant

    Here’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
    }
    ?>

    #14470

    Vera
    Participant

    The 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'];

    #14471

    myranie
    Participant

    Yeah :) It’s working …. thank you so much for your help :)

    #14472

    iheartchu
    Participant

    Hey!

    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:

    Non-working 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!!!

    #14473

    Kitty
    Participant

    What 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.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.