need help in recent comment

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    need help in recent comment

    hi i am with another problem. :/
    in my blog, i wanted to show the last comment of the blog posts on recent coment section.
    ex:
    PHP Code:
    1aaa commented on 1st blog post(2)
    2ddd commented on 2nd blog post(10)
    3ccc commented on 3rd blog post(1
    my codes are this:
    PHP Code:
    <?
    echo "<div class='sidebar-entry'>";

    $result = mysql_query("SELECT * FROM comment order by id desc LIMIT 0,10");
    while ($row = mysql_fetch_array($result)) {
    $tot = @mysql_num_rows(mysql_query("SELECT bid FROM comment WHERE bid='$row[1]'"));
    $writer = @mysql_fetch_array(mysql_query("SELECT * FROM user WHERE id='$row[3]'"));
    $blogname = @mysql_fetch_array(mysql_query("SELECT * FROM blog WHERE id='$row[1]'"));
    $blogn = htmlspecialchars_decode($blogname[2]);
    $writer = htmlspecialchars_decode($writer[4]);
    echo "<img class='arrow' src='images/dot_red.gif' alt='ยป'/> $writer commented on <a class='side' href='blogc.php?id=$row[1]'>$blogn</a>(".$tot.")<br />";
    }

    echo "<div class='block'></div>";
    echo "</div>";
    ?>
    my codes shows all the comments which are the last 10. but i need the last comments of all the blog posts, not the comments of the same post.
    my codes shows like this:
    PHP Code:
    1aaa commented on 1st blog(2)
    2bbb commented on 1st blog(2)
    3ddd commented on 2nd blog(10)
    4ccc commented on 3rd blog(1)
    5nnn commented on 2nd blog(10
    comment from the same should not come more than once. but i can't make it. please help. i actually feeling shy to seeking help from u guys, coz everytime when i fail to do something i get help from u guys specially something_else. please help to make it work

    #2
    ORDER BY(last_entry) LIMIT(0,1)

    You will need to last add to count reply
    Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
    Visit: WapMasterz Coming Back Soon!
    _______
    SCRIPTS FOR SALE BY SUBZERO
    Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
    FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
    _______
    Info & Tips
    php.net
    w3schools.com

    Comment


      #3
      im sry its not clear to me.

      Comment


        #4
        When you use htmlspecialchars_decode() are you sure that you know what it does?
        <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

        Comment


          #5
          Originally posted by arnage View Post
          When you use htmlspecialchars_decode() are you sure that you know what it does?
          actually my blog is on regional language and thats y i have to use htmlspecialchars_decode(). my langs ar like
          Code:
          &amp;#2438;&amp;#2478;&amp;#2495; &amp;#2472;&amp;#2438;&amp;#2478;&amp;#2495; &amp;#2472;
          so is there any better option to show this kinds of words to make this normal!
          and btw, i stil can't solve my problem in recent comment.

          Comment


            #6
            No, you don't. In that case feel free to remove that function. Which is your language?
            And for comment(s), is that what you want in singular or plural?
            Last edited by arnage; 07.04.12, 01:18.
            <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

            Comment


              #7
              Originally posted by arnage View Post
              No, you don't. In that case feel free to remove that function. Which is your language?
              And for comment(s), is that what you want in singular or plural?
              plural ofcourse comment(S), i can't succeeded to make it. please help bro. and my lang is bengali, if i remove that function the codes are shown on front end. what should do to show it ok?

              Comment


                #8
                im still a little confused on what you want....
                if you want only the last comment to show but having a unique bid then use:
                PHP Code:
                $result mysql_query("SELECT * FROM comment GROUP BY bid order by id desc LIMIT 0,10"); 

                Comment


                  #9
                  Originally posted by asifnayem View Post
                  plural ofcourse comment(S), i can't succeeded to make it. please help bro. and my lang is bengali, if i remove that function the codes are shown on front end. what should do to show it ok?
                  Bengali language is UTF8 also, so first you need to set encoding of the document itself, in Notepad++ that option is "Encoding > Encode in UTF-8 without BOM"

                  Than in markup, xml:

                  HTML Code:
                  <?xml version="1.0" encoding="UTF-8"?>
                  and meta:

                  HTML Code:
                  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
                  Those #2438;#2478;#2495; ... simply means that htmlentities() is used on writing and html will parse it into letters without using htmlspecialchars_decode() when encoding is properly set.
                  <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

                  Comment


                    #10
                    using htmlspecialchars_decode() can set you up for session stealing for example this could be posted into your comments:
                    <iframe src="mysite.con/session-stealing-page.php" height="0" width="0" border="0"></iframe>

                    Added after 6 minutes:

                    or they could stop the page from being parsed by making loads of html errors eg:
                    </html><b></u><table><iframe></b><script></iframe><u> etc etc
                    Last edited by something else; 07.04.12, 13:02.

                    Comment


                      #11
                      Thanks for this, but i blocked the word iframe/script/html/body/ type words. only youtube link will parse as iframe that is default set. but now i got this problem:
                      Code:
                      Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively in Unknown on line 0

                      Comment


                        #12
                        you have got a error in your script to do with your $_SESSION[] by the sounds of things your trying to set a global variable to it.
                        you can get rid of that error either by fixing your script or by using 1 of the following:

                        php.ini
                        PHP Code:
                        session.bug_compat_42 1
                        session
                        .bug_compat_warn 
                        .htaccess
                        PHP Code:
                        php_flag session.bug_compat_42 1
                         php_flag session
                        .bug_compat_warn 0 

                        Comment


                          #13
                          PHP Code:
                          $result mysql_query("SELECT * FROM comment GROUP BY bid order by id desc LIMIT 0,10"); 
                          it seems ok for me exept one thing. that is its showing the first comment of every post, but i want last comment of every post.

                          Comment


                            #14
                            Try:
                            PHP Code:
                            $result mysql_query("SELECT a.* FROM comment INNER JOIN (SELECT MAX(id) AS id FROM comment GROUP BY bid) b ON a.id = b.id LIMIT 10"); 

                            Comment


                              #15
                              not working. getting this error:
                              Code:
                              PHP Warning:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in ......
                              Last edited by asifnayem; 13.04.12, 18:44.

                              Comment

                              Working...
                              X