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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:02:03+00:00 2026-05-31T06:02:03+00:00

I have function which selects data from MySQL database: function get_articles( $id ){ global

  • 0

I have function which selects data from MySQL database:

function  get_articles( $id ){
  global $pdo;
  $query = $pdo->prepare('
    SELECT id_news, number, title, content
    FROM page_news
    WHERE number = :id
    ');
  $query->execute( array( ':id' => $id ) );
  return $query->fetchAll( PDO::FETCH_OBJ );
}

Next, I am creating a new variable:

$articles = get_articles( $_GET['id'] );

If I print_r($articles); everything seems okay. Required table is printed:

Array
(
[0] => stdClass Object
    (
        [id_news] => 226
        [number] => 14
        [title] => Cupcake ipsum dolor sit. Amet cotton candy I love I love bonbon.
        [content] => I love cotton candy I love sweet roll halvah cheesecake oat cake pastry halvah. Bonbon danish I love lemon drops chocolate candy canes jelly beans jelly-o. Tiramisu topping donut chocolate cake. Candy canes wafer icing cheesecake candy applicake tiramisu.
                     I love chocolate sugar plum chocolate bar. Jujubes wafer lollipop marshmallow halvah sesame snaps brownie icing sweet roll. 
    )
)

But when I am trying to echo any value with eg.:

echo "<p>{$articles->content}</p>";

nothing is being printed (an empty paragraph is created) and I cannot find out where the problem is.
I have another similar function which selects different data in the same way and printing out works perfectly.

  • 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-31T06:02:04+00:00Added an answer on May 31, 2026 at 6:02 am

    It’s array. You must use

    echo "<p>{$articles[0]->content}</p>";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code which selects data from my database and then sets these selected
I have postgresql (in perlu) function getTravelTime(integer, timestamp), which tries to select data for
I have a little dropdown menu similar <select> , which contolled from external js-function.
i am reading data from a mysql database table. I have populated a dropdown
I have the following C# code, which pulls data from a database & populates
i have function which is something like this function multiple_delete($entity1,$entity2,$entity2) { $query = SELECT
I have an function which decodes the encoded base64 data in binary data but
I have a function which gets a key from the user and generates a
i have a function which retrieves values from a webservice , then loops through
Hey guys I have an ajax jquery function that receives data from a php

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.