+ Reply to Thread
Results 1 to 5 of 5

Thread: "Status updates"

  1. #1
    gdebojyoti.mail96 is offline x10Hosting Member gdebojyoti.mail96 is an unknown quantity at this point
    Join Date
    Mar 2011
    Posts
    57

    Question "Status updates"

    I am planning to introduce Facebook/ Orkut/ Twitter like "status update" feature to the members of my website. But I am not sure about where and how to store the data posted by the users (i.e., the contents of the "status"). Can someone please suggest a way?
    Note that I would also like to display older updates (newest first).
    And what measures should I take to prevent SQL injections? I also want to display the exact data that a user enters (such as "<b>Text</b>", and not "Text" ), just like Facebook.

    Looking forward to your help.

    Regards.

  2. #2
    gdebojyoti.mail96 is offline x10Hosting Member gdebojyoti.mail96 is an unknown quantity at this point
    Join Date
    Mar 2011
    Posts
    57

    Re: "Status updates"

    I am still waiting for a reply.... Anyone there?? Help is urgently required!!

  3. #3
    veliisx235 is offline x10Hosting Member veliisx235 is an unknown quantity at this point
    Join Date
    Aug 2011
    Posts
    2

    Wink Re: "Status updates"

    I would definitely store the data using SQL (most likely in a VARCHAR field). The way you need to handle the special characters is going to depend on how you are displaying the status. Most likely you will need to figure out all the special characters possible and use escape sequences so that they don't behave like HTML (if you are using PHP).

    Using SQL, if you use an auto incrementing value for the KEY (or you manually shove in a time stamp) you can have it sort for you when you pull them out of the database quite easily.

  4. #4
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: "Status updates"

    Consider how to model the data before considering what you want to do with it, because what you want to do with it may change in the future. Just designing the model may give you ideas about how to use it. Consider the properties of what you're modeling. There's the status text, the user and the date & time that the status was changed; you may be able to think of others that would be useful. The properties become columns in a "statuses" table (use a table separate from your table of users, since users and statuses have a 1-to-many relationship). The date & time let you sort statuses. The user can be joined to other tables for various purposes (e.g. a "friends' statuses" page).

    SQL injection is prevented by using prepared statements, passing the values via prepared statement parameters.

    When it comes time to post the status text, pass it through "htmlspecialchars" before outputting it to encode characters that are, well, special in HTML. You may be tempted to do this before storing the text, but (generally speaking) you should only format data for a given purpose when it comes time to use the data for that purpose. You can't be certain that the status text will only ever be used by HTML processors and you'll gain nothing appreciable by pre-processing before storage.

    Urgency is subjective.
    Last edited by misson; 08-24-2011 at 04:11 AM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  5. #5
    gdebojyoti.mail96 is offline x10Hosting Member gdebojyoti.mail96 is an unknown quantity at this point
    Join Date
    Mar 2011
    Posts
    57

    Thumbs up Re: "Status updates"

    Thanks for your help. I have successfully managed to enable status updates in my site.

+ Reply to Thread

Similar Threads

  1. Replies: 4
    Last Post: 01-27-2011, 02:10 PM
  2. Hosting Unsuspension status is in "Process Wait" for a long time.
    By sheikdprogrammer32 in forum Free Hosting
    Replies: 3
    Last Post: 09-09-2010, 12:14 AM
  3. Replies: 1
    Last Post: 05-08-2010, 03:17 AM
  4. Unsuspension Status "Unknown" account "jchevin"
    By 200206695 in forum Free Hosting
    Replies: 8
    Last Post: 10-03-2009, 06:37 PM
  5. Replies: 4
    Last Post: 11-27-2007, 06:49 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers