Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6637279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:17:38+00:00 2026-05-25T23:17:38+00:00

Question: Should I decouple the SESSION variables, i.e. move them outside of the class…this

  • 0

Question:

Should I decouple the SESSION variables, i.e. move them outside of the class…this was a suggestion from another POST. I would like to extend this library to more general cases than just for my purposes..and I believe this is the next step here?

Summary:

This class sends “tweet” data to the client in the form of a custom markup language.

It is used in Ajax call and in previous post people have suggested not to echo the result..but this is my primary means of communicating with the server via Ajax responseText.

Also <tw_p> is used to denote a pass and is read by the client. The markup looks like this.

field 1 | field 2 | field 3 | field 4 || field 1 | field 2 | field 3 | field 4 ||

It is called like this –

new tweet();

The client knows how render this into xhtml once it receives it.

/*tweet*/

class tweet extends post
  {
  function __construct()
    {
    parent::__construct();
    $email=$_SESSION['email'];
    $flname=$_SESSION['name'];
    $message=$this->_protected_arr['f4b'];
    $time=time();
    database::query("INSERT INTO tw VALUES ('$time','$flname','$message','$email')");        
    $query_return = database::query("SELECT * FROM tw ORDER BY time DESC LIMIT 7");
    $b=0;
    $c='<tw_p>';
    while($a=mysqli_fetch_assoc($query_return))
      {  
      if($b==0)
        {
        $c = $c . $a['email'] . "|" .  $a['fname'] . "|" . $a['time'] . "|" . $time . "|" . $a['message'];
        }
      else
        {
        $c = $c . "||" . $a['email'] . "|" .  $a['fname'] . "|" . $a['time'] . "|" . $time . "|" . $a['message'];
        }
      $b++;
      }
    echo $c;
    }
  }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:17:39+00:00Added an answer on May 25, 2026 at 11:17 pm

    What I would do if it was my code:

    1. Remove logic from constructor, it is for initialization only. Thus remove all the business logic into separate method doTheWork (choose the meaningful name that explains what happens in the code)
    2. Parametrize constructor with:
      • email
      • name
      • database instance (yes, I’d avoid static database::query() method)
    3. Remove echo $c; in the end and replace it with return $c;
    4. Remove the presentation logic from this class outside (the lines with || stuff)
    5. Sanitize the data used in the query (thanks to vzwick)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edited Question: This should be clear. using System; namespace UpdateDateTimeFields { class Program {
This question should serve as a listing of all the different content-editable solutions. Post
This question should be quite clear from its title alone, but let me explain
This is a follow-up to the question: Should the folders in a solution match
[EDIT] Hmm. Perhaps this question should be titled what is the default user-input dialog
This may not be the kind of question one should ask on StackOverflow, but
I think I shall reframe my question from Where should you use BlockingQueue Implementations
This should a quick question for some easy rep. I'm doing some PHP Website
(This question should probably be answered with a reference to Stroustrup.) It seems extremely
It seemed like this question should have been asked before, but searching found nothing.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.