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 6355937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:52:01+00:00 2026-05-24T22:52:01+00:00

All my website functions are like the one i will paste below. i wanted

  • 0

All my website functions are like the one i will paste below.
i wanted to ask,
has this function any possible bug ? will this function make the server load hard ? can you suggest anything better for my website ? there are a lot of pageviews at my web, so i need to get my data without loading hard my server.

the code ( this is used to get the single posts.)

function single($id = '') {
    $id = mysql_real_escape_string ($id);
    $sql = 'SELECT id,post_title,post_date,post_content FROM wp_posts WHERE id='.$_GET['id'].'  LIMIT 1';
    $res = mysql_query($sql) or die (mysql_error());    

if (mysql_num_rows($res) !=0):
    while ($row = mysql_fetch_assoc($res)) {

    //this filter the content from the database
    $mycontent = $row['post_content'];
    $mycontent = strip_tags($mycontent);
    $mycontent = preg_replace("/\[caption.*\[\/caption\]/", '', $mycontent); 
    $mycontent = htmlentities($mycontent);

    //this make possible  to show special characters on title
    $title = $row['post_title'];
    $title = htmlentities($title);

    //date format
        $old_date = $row['post_date'];            
    $old_date_timestamp = strtotime($old_date);
    $new_date = date('d.m.Y   H:i', $old_date_timestamp); 

    //get first post image
    $first_img = '';
    ob_start();
    ob_end_clean();
    $my1content = $row['post_content'];
    $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $my1content, $matches); 
    $first_img = $matches [1] [0];
    if(empty($first_img)){ //Defines a default image
    $first_img = "/img/default.png";
    }

    echo '
        <div class="single-header">
        <div class="single-title">'.$title.'</div>  
        <div class="single-tr"> '.$new_date.'</div> 
        </div><!-- single header -->
        <div class="single-print"></div><!-- print -->
        <div class="single-content">
        <div class="single-img">
        <img src="timthumb.php?src='.$first_img.'&amp;h=223&amp;w=395&amp;zc=1" alt="" />
        </div>
        <div class="single-text">'.$mycontent.' </div>
        </div> <!-- content -->
    '; //echo
}
    else:
        echo 'Dont exist';
    endif;
} // end

This is very important for me , please check it , any kind of help will be just great

Thank you a lot for reading this thread.

  • 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-24T22:52:02+00:00Added an answer on May 24, 2026 at 10:52 pm
    1. Security: you are mysql-real-escaping the $id from the function call, but including $_GET['id'] into the query…
    2. There is nothing between ob_start(); and ob_end_clean();, so its useless
    3. I would make some minor changes just for readability:

    .

    // e.g. instead
    $title = $row['post_title'];
    $title = htmlentities($title);
    // do
    $title = htmlentities($row['post_title']);
    

    EDIT:

    As this seems to be a function for WordPress, you may use the wpdb-class instead of using mysql-functions directly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a website with all my photos, I would like people to be
I want to make one website for all PC, IPhone, Blackberry, Windows Mobile (IE
My employers website has multiple hostnames that all hit the same server and we
one of my clients has a website which has been totally messed up by
Let's say I want to create a website that contains one page. All the
I am not sure if this is possible, I am working on a website
My CSS for the website all looks fine in Firefox but in both Chrome
When i use php include to include a page in my website all the
I have a website where all requests are redirected silently (via .htaccess ) to
I'm trying to make a Google Maps widget for my website but all of

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.