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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:08:43+00:00 2026-06-11T11:08:43+00:00

I have this piece of code: private function grabCurrentUser() { $this->id = parent::secure($_GET[‘cid’]); $params

  • 0

I have this piece of code:

private function grabCurrentUser() {

    $this->id = parent::secure($_GET['cid']);

    $params = array( ':user_id' => $this->id );
    $stmt   = parent::query("SELECT * FROM users WHERE user_id = :user_id;", $params);

    if( $stmt->rowCount() < 1 ) parent::displayMessage("<div class='alert alert-error'>"._('No such user!')."</div>");

    foreach ($stmt->fetch(PDO::FETCH_ASSOC) as $field => $value)
        $this->options[$field] = $value;

}

I want to replace the error message on it, so instead of having this error message:

parent::displayMessage("<div class='alert alert-error'>"._('No such user!')."</div>

I want to include index.php like so:

include_once(cINC . 'index.php');

So how can I replace it from showing an error message to just including index.php?

I tried this:

private function grabCurrentUser() {

    $this->id = parent::secure($_GET['cid']);

    $params = array( ':user_id' => $this->id );
    $stmt   = parent::query("SELECT * FROM users WHERE user_id = :user_id;", $params);

    if( $stmt->rowCount() < 1 ) include_once(cINC . 'index.php');

    foreach ($stmt->fetch(PDO::FETCH_ASSOC) as $field => $value)
        $this->options[$field] = $value;

}

But got this error:

Warning: Invalid argument supplied for foreach() 

Thanks in advance

  • 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-11T11:08:44+00:00Added an answer on June 11, 2026 at 11:08 am

    You had mistake in application logic, if you don’t have any records and want to include some file then you don’t iterate through empty record list.

    private function grabCurrentUser() {
    
        $this->id = parent::secure($_GET['cid']);
    
        $params = array( ':user_id' => $this->id );
        $stmt   = parent::query("SELECT * FROM users WHERE user_id = :user_id;", $params);
    
        if( $stmt->rowCount() < 1 ){
            include_once(cINC . 'index.php');
        } else {
            foreach ($stmt->fetch(PDO::FETCH_ASSOC) as $field => $value)
                $this->options[$field] = $value;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this piece of code: private void myFunc(){ obj = doSomething(); //If value
I have this piece of code in c#: private static void _constructRow(SqlDataReader reader, system.IO.StreamWriter
I have this piece of code in a function. I want to print the
I have this piece of code: private void prepareContent() { log.info(do something); // success?
I have this piece of code and it's causing NullPointerException private List<Player> playerList; private
As I have already done, I have this piece of code: private string opt;//
I have this piece of LINQ code private static void Original() { using (var
I have this piece of code (or similar) in many of our views: private
I have this piece of code in my Silverlight project: private void button1_Click(object sender,
I have this piece of code: public static DateDialogFragment newInstance(Context context, DateDialogFragmentListener listener) {

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.