Results 1 to 13 of 13

Thread: facebook style wallpost- can post in realtime but when refresh i dont get prev posts!

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2010
    Posts
    15

    facebook style wallpost- can post in realtime but when refresh i dont get prev posts!

    Hey guys,

    im having issues with showing current posts when i visit the page again on a facebbok like wall post script.

    it shows posts that im currently making fine but as soon as i go to refresh the page the posts disapear.

    i have added all the codes below in a file so u have all the script.

    Though i would add the main 4 bits of code here.

    Facebook_Wall_Script.PHP
    PHP Code:

    PHP Code
    :
    <!
    DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3
    .org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
    ><html xmlns="http://www.w3.org/1999
    /xhtml"
    ><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1
    /><title>9lessons Applicatio Demo</title><link href="frame.css" rel="stylesheet" type="text/css"><script type="text/javascript" 
    src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>  <script type="text/javascript" src="jquery.oembed.js"></script>  <script 
    type
    ="text/javascript">$(function() {$(".comment_button").click(function() {var element
     
    = $(this);       var boxval = $("#content").val();        var dataString 'content='
    boxval;        if(boxval=='')    {    alert("Please Enter Some Text");        }    else    {    $("#flash").show();    $("#flash").fadeIn(400).html('<img src="ajax.gif" 
    align="absmiddle">&nbsp;<span class="loading">Loading Update...</span>'
    );$.ajax({   
         
    type"POST",  url"update_ajax.php",   datadataString,  cachefalse,  success
    function(
    html){   $("ol#update").prepend(html);  $("ol#update li:first").slideDown("slow");     document.getElementById('content').value='';   $('#content').value='';   $('#content').focus();  $("#flash").hide();          $("#expand_url").oembed(boxval);      } });}return false;    });// delete undate$('.delete_update').live("click",function() {var ID = $(this).attr("id");var dataString = 'msg_id='+ ID;if(confirm("Sure you want to delete this update? There is NO undo!")){$.ajax({        type: "POST",  url: "delete_update.php",   data: dataString,  cache: false,  success: function(html){  $(".bar"+ID).slideUp();      } });}return false;});//comment slide$('.comment').live("click",function() {var ID = $(this).attr("id");$(".fullbox"+ID).show();$("#c"+ID).slideToggle(300);return false;});//commment Submint$('.comment_submit').live("click",function() {var ID = $(this).attr("id");var comment_content = $("#textarea"+ID).val();        var dataString = 'comment_content='+ comment_content + '&msg_id=' + ID;        if(comment_content=='')    {    alert("Please Enter Comment Text");        }    else  
      
    {              $.ajax({        type"POST",  url"comment_ajax.php",   datadataString,  
    cachefalse,  success: function(html){     $("#commentload"+ID).append(html);    document.getElementById("textarea"+ID).value='';      $("#textarea"+ID).focus
    ();    } });            }return false;});//comment delete$('.cdelete_update').live
    ("click",function() {var ID = $(this).attr("id");var dataString 'com_id='ID;if(confirm
    ("Sure you want to delete this update? There is NO undo!")){$.ajax({        type"POST"
     
    url"delete_comment.php",   datadataString,  cachefalse,  success: function(html){  $("#comment"+ID).slideUp();      } });}return false;});return false;});</script><style type="text/css">body{font-family:ArialHelveticasans-serif;font-size:12px;}.update_box{background-color:#D3E7F5; border-bottom:#ffffff solid 1px; padding-top:3px}a    {    text-decoration:none;    color:#d02b55;    }    a:hover    {    text-
    decoration:underline;    color:#d02b55;    }    *{margin:0;padding:0;}            ol.timeline    {list-style:none;font-size:1.2em;}ol.timeline li{ display:none;position:relative; }ol.timeline li:first-child{border-top:1px dashed #006699;}    .delete_button    {    float:right; margin-right:10px; width:20px; height:20
    px    }        .cdelete_button    {    float:rightmargin-right:10pxwidth:20pxheight:20
    px    
    }        .feed_link    {    font-style:inheritfont-family:Georgiafont-size:13px;padding:10pxfloat:leftwidth:350px    }    .comment    {    color:#0000CC; text-decoration:underline    }    .delete_update    {    font-weight:bold;        }    .cdelete_update    {    font-weight:bold;        }    .post_box    {    height:55px;border-bottom:1px dashed #006699;background-color:#F3F3F3;  width:499px;padding:.7em 0 .6em 0;line-height:1.1em;        }    #fullbox    {    margin-top:6px;margin-bottom:6px; display:none;    }    .comment_box    {        display:none;margin-
    left:90pxpadding:10pxbackground-color:#d3e7f5; width:300px;  height:50
    px;        }    .comment_load    {      margin-left:90pxpadding:10pxbackground-color:#d
    3e7f5width:300pxheight:30pxfont-size:12pxborder-bottom:solid 1px #FFFFFF;        }    .text_area    {    width:290px;    font-size:12px;    height:30
    px;    }    #expand_box    {    margin-left:90px;    margin-top:5px;    margin-bottom:5
    px;    }    embed    {        width:200px;        height:150px;    }    
    </
    style></head><body><div align="center"><table cellpadding="0" cellspacing="0" width="500px"><tr><td><div align="left"><form  method="post" name="form" action=""><table 
    cellpadding
    ="0" cellspacing="0" width="500px"><tr><td align="left"><div align="left"><h3
    >What are you doing?</h3></div></td></tr><tr><td style="padding:4px; padding-left:10
    px;" 
    class="update_box"><textarea cols="30" rows="2" style="width:480px;font-size:14px; font-weight:bold" name="content" id="content" maxlength="145" 
    ></textarea><br /><input type="submit"  value="Update"  id="v" name="submit" 
    class="comment_button"/></td></tr></table></form></div><div style="height:7
    px"
    ></div><div id="flash" align="left"  ></div><ol  id="update" 
    class="timeline"></ol></td></tr></table></div></body></html
    comment_ajax.PHP
    PHP Code:
    <?php include("db.php");if(isSet($_POST['comment_content'])){$id=time();// Demo Use$comment=$_POST['comment_content'];$msg_id=$_POST['msg_id'];$sql=mysql_query("insert into comments(comment,msg_id_fk)values('$comment','$msg_id')");$result=mysql_query("select * from comments order by com_id desc");$row=mysql_fetch_array($result);$id=$row['com_id'];$comment=$row['comment'];}?> <div class="comment_load" id="comment<?php echo $id?>"> <?php echo $comment;  ?> <span class="cdelete_button"><a href="#" id="<?php echo $id?>" class="cdelete_update">X</a></span> </div>
    update_ajax.PHP
    PHP Code:
    <?phpinclude("../../settings.php");include("tolink.php");//if(isSet($_POST['content']))$id=time();//Demo Use$msg=$_POST['content'];$sql=mysql_query("insert into messages2(message)values('$msg')")or die(mysql_error());$result=mysql_query("select * from messages2 order by msg_id desc")or die(mysql_error());$row=mysql_fetch_array($result);$id=$row['msg_id'];$msg=$row['message'];$msg=toLink($msg);?> <li class="bar<?php echo $id?>"><div align="left" class="post_box"><span style="padding:10px"><?php echo $msg?> </span><span class="delete_button"><a href="#" id="<?php echo $id?>" class="delete_update">X</a></span><span class='feed_link'><a href="#" class="comment" id="<?php echo $id?>">comment</a></span></div><div id='expand_box'><div id='expand_url'></div></div><div id="fullbox" class="fullbox<?php echo $id?>"><div id="commentload<?php echo $id?>" ></div><div class="comment_box" id="c<?php echo $id?>"><form method="post" action="" name="<?php echo $id?>"><textarea class="text_area" name="comment_value" id="textarea<?php echo $id?>"></textarea><br /><input type="submit" value=" Comment " class="comment_submit" id="<?php echo $id?>"/></form></div></div></li>
    Last edited by Hack; Apr 23rd, 2010 at 11:25 AM.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: facebook style wallpost- can post in realtime but when refresh i dont get prev po

    What does this have to do with VB.NET?

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2010
    Posts
    15

    Re: facebook style wallpost- can post in realtime but when refresh i dont get prev po

    sorry which forum should have i posted it in?

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: facebook style wallpost- can post in realtime but when refresh i dont get prev po

    The PHP section, which is where I have just moved it for you.

    Welcome to the forums

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2010
    Posts
    15

    Re: facebook style wallpost- can post in realtime but when refresh i dont get prev po

    thanks sorry...

    here is a link to the working code so you can see whats wrong

    http://www.runningprofiles.com/membe...all_Script.php

  6. #6
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: facebook style wallpost- can post in realtime but when refresh i dont get prev po

    When you post code samples, please post them in readable formatting; use line breaks, indentation, etc. Otherwise it's much harder than it needs to be to offer you any help.

    From your description of the problem, it sounds like the new posts are not being saved to the database correctly. Check that your connection credentials are valid. I will see if I can offer more specific advice once I've deciphered your code blobs...

    Edit: Wait, no - it's saving to the database correctly. You're just not calling up any previously-saved comments on Facebook_Wall_Script.PHP.
    Last edited by SambaNeko; Apr 23rd, 2010 at 11:57 AM.

  7. #7

    Thread Starter
    New Member
    Join Date
    Apr 2010
    Posts
    15

    Re: facebook style wallpost- can post in realtime but when refresh i dont get prev po

    I have added the file in a zip file to make it easyer for you.

    The code is inserting the code into the db fine as i can see it in there.

    Any help would be greatly appresiated and any more info needed i can supply no problem.
    Attached Files Attached Files

  8. #8
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: facebook style wallpost- can post in realtime but when refresh i dont get prev po

    As said in my edit, you'll need to call up the previous comments on Facebook_Wall_Script.PHP. So, around here:
    Code:
    <ol id="update" class="timeline"></ol>
    ...you'll need some PHP. Here's some lousy pseudo-code:
    Code:
    <ol id="update" class="timeline">
    <?php
    //SQL: get previous comments
    //loop SQL result to make <li> elements with the previous comments
    //the ajax posts will add new comments to this list
    ?>
    </ol>
    Are you well-versed in PHP/MySQL? Do you already understand and know how to do this or need a more thorough example?

  9. #9

    Thread Starter
    New Member
    Join Date
    Apr 2010
    Posts
    15

    Re: facebook style wallpost- can post in realtime but when refresh i dont get prev po

    Ok i tried this

    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>9lessons Applicatio Demo</title>
    <link href="frame.css" rel="stylesheet" type="text/css"><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
      <script type="text/javascript" src="jquery.oembed.js"></script>
     
     <script type="text/javascript">


    $(function() {

    $(".comment_button").click(function() {

    var element = $(this);
       
        var boxval = $("#content").val();
        
        var dataString = 'content='+ boxval;
        
        if(boxval=='')
        {
        alert("Please Enter Some Text");
        
        }
        else
        {
        $("#flash").show();
        $("#flash").fadeIn(400).html('<img src="ajax.gif" align="absmiddle">&nbsp;<span class="loading">Loading Update...</span>');
    $.ajax({
            type: "POST",
      url: "update_ajax.php",
       data: dataString,
      cache: false,
      success: function(html){
     
      $("ol#update").prepend(html);
      $("ol#update li:first").slideDown("slow");
      
       document.getElementById('content').value='';
       $('#content').value='';
       $('#content').focus();
      $("#flash").hide();
      
        
        $("#expand_url").oembed(boxval);
        
      }
     });
    }
    return false;
        });


    // delete undate
    $('.delete_update').live("click",function() 
    {
    var ID = $(this).attr("id");
    var dataString = 'msg_id='+ ID;

    if(confirm("Sure you want to delete this update? There is NO undo!"))
    {
    $.ajax({
            type: "POST",
      url: "delete_update.php",
       data: dataString,
      cache: false,
      success: function(html){
     
     $(".bar"+ID).slideUp();
        
      }
     });

    }
    return false;
    });


    //comment slide
    $('.comment').live("click",function() 
    {

    var ID = $(this).attr("id");
    $(".fullbox"+ID).show();
    $("#c"+ID).slideToggle(300);

    return false;
    });


    //commment Submint

    $('.comment_submit').live("click",function() 
    {

    var ID = $(this).attr("id");

    var comment_content = $("#textarea"+ID).val();
        
        var dataString = 'comment_content='+ comment_content + '&msg_id=' + ID;
        
        if(comment_content=='')
        {
        alert("Please Enter Comment Text");
        
        }
        else
        {
        
       
           $.ajax({
            type: "POST",
      url: "comment_ajax.php",
       data: dataString,
      cache: false,
      success: function(html){
      
     
      $("#commentload"+ID).append(html);
        document.getElementById("textarea"+ID).value='';
       
       $("#textarea"+ID).focus();
      
      }
     });
        
        
        }

    return false;
    });

    //comment delete
    $('.cdelete_update').live("click",function() 
    {
    var ID = $(this).attr("id");

    var dataString = 'com_id='+ ID;

    if(confirm("Sure you want to delete this update? There is NO undo!"))
    {
    $.ajax({
            type: "POST",
      url: "delete_comment.php",
       data: dataString,
      cache: false,
      success: function(html){
     
     $("#comment"+ID).slideUp();
        
      }
     });
    }
    return false;
    });




    return false;

    });


    </script>


    <style type="text/css">
    body
    {
    font-family:Arial, Helvetica, sans-serif;
    font-size:12px;
    }
    .update_box
    {
    background-color:#D3E7F5; border-bottom:#ffffff solid 1px; padding-top:3px
    }
    a
        {
        text-decoration:none;
        color:#d02b55;
        }
        a:hover
        {
        text-decoration:underline;
        color:#d02b55;
        }
        *{margin:0;padding:0;}
        
        
        ol.timeline
        {list-style:none;font-size:1.2em;}ol.timeline li{ display:none;position:relative; }ol.timeline li:first-child{border-top:1px dashed #006699;}
        .delete_button
        {
        float:right; margin-right:10px; width:20px; height:20px
        }
        
        .cdelete_button
        {
        float:right; margin-right:10px; width:20px; height:20px
        }
        
        .feed_link
        {
        font-style:inherit; font-family:Georgia; font-size:13px;padding:10px; float:left; width:350px
        }
        .comment
        {
        color:#0000CC; text-decoration:underline
        }
        .delete_update
        {
        font-weight:bold;
        
        }
        .cdelete_update
        {
        font-weight:bold;
        
        }
        .post_box
        {
        height:55px;border-bottom:1px dashed #006699;background-color:#F3F3F3;  width:499px;padding:.7em 0 .6em 0;line-height:1.1em;
        
        }
        #fullbox
        {
        margin-top:6px;margin-bottom:6px; display:none;
        }
        .comment_box
        {
            display:none;margin-left:90px; padding:10px; background-color:#d3e7f5; width:300px;  height:50px;
        
        }
        .comment_load
        {
          margin-left:90px; padding:10px; background-color:#d3e7f5; width:300px; height:30px; font-size:12px; border-bottom:solid 1px #FFFFFF;
        
        }
        .text_area
        {
        width:290px;
        font-size:12px;
        height:30px;
        }
        #expand_box
        {
        margin-left:90px;
        margin-top:5px;
        margin-bottom:5px;
        }
        embed
        {
            width:200px;
            height:150px;

        }
        
    </style>
    </head>

    <body>
    <?php include '../../settings.php'?>

    <div align="center">
    <table cellpadding="0" cellspacing="0" width="500px">
    <tr>
    <td>


    <div align="left">
    <form  method="post" name="form" action="">
    <table cellpadding="0" cellspacing="0" width="500px">

    <tr><td align="left"><div align="left">
    <h3>What are you doing?</h3></div></td></tr>
    <tr>
    <td style="padding:4px; padding-left:10px;" class="update_box">
    <textarea cols="30" rows="2" style="width:480px;font-size:14px; font-weight:bold" name="content" id="content" maxlength="145" ></textarea><br />
    <input type="submit"  value="Update"  id="v" name="submit" class="comment_button"/>
    </td>

    </tr>

    </table>
    </form>




    </div>
    <div style="height:7px"></div>
    <div id="flash" align="left"  ></div>



    <ol  id="update" class="timeline">
    <?php
    $sql 
    "select * from messages2 order by msg_id desc";
    $result mysql_query($sql) or die("Could not get threads");
    while(
    $row mysql_fetch_assoc($result))
    {
        
    $id=$row['msg_id'];
    $msg=$row['message'];
        
    ?>
        
     <li class="bar<?php echo $id?>">
    <div align="left" class="post_box">
    <span style="padding:10px"><?php echo $msg?> </span>
    <span class="delete_button"><a href="#" id="<?php echo $id?>" class="delete_update">X</a></span>
    <span class='feed_link'><a href="#" class="comment" id="<?php echo $id?>">comment</a></span>
    </div>
    <div id='expand_box'>
    <div id='expand_url'></div>
    </div>
    <div id="fullbox" class="fullbox<?php echo $id?>">
    <div id="commentload<?php echo $id?>" >

    </div>
    <div class="comment_box" id="c<?php echo $id?>">
    <form method="post" action="" name="<?php echo $id?>">
    <textarea class="text_area" name="comment_value" id="textarea<?php echo $id?>">
    </textarea><br />
    <input type="submit" value=" Comment " class="comment_submit" id="<?php echo $id?>"/>
    </form>
    </div>
    </div>


    </li>   
    <?php    
    }
    ?>
    </ol>

    </td>
    </tr>
    </table>






    </div>



    </body>
    </html>

    but it didnt show up any results in my db...

    in the db i have stored
    Code:
    INSERT INTO `messages2` (`msg_id`, `message`) VALUES ('130', '1');
    INSERT INTO `messages2` (`msg_id`, `message`) VALUES ('169', 'hey');
    INSERT INTO `messages2` (`msg_id`, `message`) VALUES ('171', 'f');
    INSERT INTO `messages2` (`msg_id`, `message`) VALUES ('165', 'nothing\n');
    INSERT INTO `messages2` (`msg_id`, `message`) VALUES ('161', 'comment');
    INSERT INTO `messages2` (`msg_id`, `message`) VALUES ('158', 'f');
    INSERT INTO `messages2` (`msg_id`, `message`) VALUES ('159', 'ff');
    INSERT INTO `messages2` (`msg_id`, `message`) VALUES ('160', 'Hello...');
    INSERT INTO `messages2` (`msg_id`, `message`) VALUES ('157', 't');
    INSERT INTO `messages2` (`msg_id`, `message`) VALUES ('156', 'tewt');
    INSERT INTO `messages2` (`msg_id`, `message`) VALUES ('155', '3');
    INSERT INTO `messages2` (`msg_id`, `message`) VALUES ('154', '2');
    INSERT INTO `messages2` (`msg_id`, `message`) VALUES ('153', '2');

  10. #10
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: facebook style wallpost- can post in realtime but when refresh i dont get prev po

    Have you connected to the database already in one of the included files? Your update_ajax.php uses the same SQL ("select * from messages2 order by msg_id desc") and is working, so it ought to be fine here too.

  11. #11

    Thread Starter
    New Member
    Join Date
    Apr 2010
    Posts
    15

    Re: facebook style wallpost- can post in realtime but when refresh i dont get prev po

    yes the db conntection is <?php include '../../settings.php'; ?>

    so it should work?!

  12. #12

    Thread Starter
    New Member
    Join Date
    Apr 2010
    Posts
    15

    Re: facebook style wallpost- can post in realtime but when refresh i dont get prev po

    ok i did this

    <?php
    $query = "SELECT * FROM messages2";
    $sqlinbox = mysql_query($query);

    //Error thingy, ohh no! Dispaly the error and the query so we can diagnose the problem if there is one
    if(!$sqlinbox)
    {
    ?>
    <p><?php print '$query: '.$query.mysql_error();?></p>
    <?php
    }
    else
    {
    echo 'yes it is';
    }



    and it echos yes it is!

  13. #13
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: facebook style wallpost- can post in realtime but when refresh i dont get prev po

    Quote Originally Posted by runnerjp View Post
    and it echos yes it is!
    So it looks like you're not having trouble getting a resource. I'm really not sure what's still going wrong at this point - your code looks fine.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width