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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:12:02+00:00 2026-06-03T04:12:02+00:00

I have been trying to pull all infomation where $user is equal to subscriberID

  • 0

I have been trying to pull all infomation where $user is equal to subscriberID in my sql database. I am using the PDO method of inserting data and wish to use the query function also.
i am getting the following error message back from my try condition.

Fatal error: Call to a member function setFetchMode() on a non-object

I have considered maybe the problem has been caused by the method i use to pull the data as im fairly new to PDO.(i include a top.php that establishes the link to the database)

Thank you for your suggestions

 <?php
 include "top.php";

    try{
        $user = $_SESSION['login'];
        echo "Welcome <strong>$user</strong> to your saved holidays";

        //$getSavedHolidays = $db->query("SELECT * FROM saved_holidays WHERE subscriberID='$user'");
        //preparing a PDO statment for accessing saved holidays when the logged in user matchs the subscriberID
        $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
        $getSavedHolidays = $db->prepare("SELECT * FROM saved_holidays WHERE subscriberID=:user");
        //uses a bind valu as this makes the statment more secure
        $getSavedHolidays->bindValue(":user", $_SESSION['login']);
        $getsavedHolidays->setFetchMode(PDO::FETCH_ASSOC);
        $getSavedHolidays->execute();


        foreach ($Result as $row)
            {
                echo "<p><a href'".$row['link']."'>".$row['title']."</a><br \>" . 
                     $row['description'] . "<br \>" . 
                     $row['pubDate'] ."<br \></p>";
            }

        }

        catch (PDOException $e) 
            {
                 print_r($e->errorInfo);
                    die();
            }

?>

  • 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-06-03T04:12:03+00:00Added an answer on June 3, 2026 at 4:12 am

    You should be preparing your statement. It has a nice added bonus of being more secure, plus it will solve your problem.

    $user = $_SESSION['login'];
    
    try {
        $db = new PDO("mysql:host=localhost;dbname=database", "user", "pass");
        $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
    
        $getSavedHolidays = $db->prepare("SELECT * FROM saved_holidays WHERE subscriberID=:user");
        $getSavedHolidays->bindValue(":user", $_SESSION['login']);
        $getSavedHolidays->setFetchMode(PDO::FETCH_ASSOC);
        $getSavedHolidays->execute();
        $Result = $getSavedHolidays->fetchAll();
    
        foreach ($Result as $row) {/*...*/}
    
    }
    catch (PDOException $e) {
        print_r($e->errorInfo);
        die();
    }
    

    EDIT

    You have an error in the code you’ve pasted above:

    $$getSavedHolidays = $db->prepare("SELECT * FROM saved_holidays WHERE subscriberID=:user");
    

    Should be

    $getSavedHolidays = $db->prepare("SELECT * FROM saved_holidays WHERE subscriberID=:user");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to pull out my SQLite database from my android application
I have been trying to use the document.getElementByID to pull information from an HTML
I am starting to pull my hair out over this! I have been trying
I have been trying all afternoon to get the jQuery Sifr Plugin ( http://jquery.thewikies.com/sifr/
I have been trying to write a bare-bones ping scanner using Perl for internal
I have been trying to build an SQL query to return matches between three
Good morning. I have been looking all over trying to answer this question. If
Been trying to figure this one out all day. I have a large text
I have been looking around for a jQuery json method to pull in stats
Have have been trying to make a validator for my xml files. I have

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.