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

  • Home
  • SEARCH
  • 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 8660989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:23:15+00:00 2026-06-12T16:23:15+00:00

I write this in a page : require_once(pdf/tab_activite.php); … foreach ($tab[activite] as $key =>

  • 0

I write this in a page :

require_once("pdf/tab_activite.php");
...
foreach ($tab["activite"] as $key => $value) 
{
   ...
}

Inside the tab_activite.php there is this :

...
$list = new activite($this->db);
$list->lireParNiveau($critere);
$tab["activite"] = $list->tableau ;
...

Then in the log there is :

[10-Oct-2012 10:30:48] PHP Notice:  Undefined index:  activite in C:\wamp\www\mp\models\objet.class.php on line 543
[10-Oct-2012 10:30:48] PHP Warning:  Invalid argument supplied for foreach() in C:\wamp\www\mp\models\objet.class.php on line 543

So how to manipulate correctly the $tab[“activite”] variable ?

  • 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-12T16:23:16+00:00Added an answer on June 12, 2026 at 4:23 pm

    Since the require_once() is called inside a function, $tab["activite"] exists only in that function’s scope. Add the statement global $tab; to the file tab_activite.php before using the $tab variable to extend it’s scope so that the main program can see it as well.

    global $tab;
    $list = new activite($this->db);
    $list->lireParNiveau($critere);
    $tab["activite"] = $list->tableau ;
    

    EDIT: Another problem could occur if you call the function multiple times, as the file is included only once when using require_once(). If this is the case, replace require_once() with require() and see if that helps.

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

Sidebar

Related Questions

how can i write this code from aspx page in code behind? <a href=skype:MySkype?call><img
I am talking about doing something like this: LOCK TABLE page WRITE; SELECT *
i write this in .emacs (require 'dired-x) (global-set-key (kbd C-x C-j) 'dired-jump) but when
In wordpress <?php bloginfo('url'); ?> is the main page's url, then, how to write
On this site each page is made up of multiple .jsp files. There is
Example: This white space is rendered because of some php I use inside my
I wrote this method to check if a page exists or not: protected bool
Hey I wrote this to grab get a FB page feed and output it
Possible Duplicate: White space at bottom of anchor tag Check out this sample page
I wrote a Delphi function retrieving a web page from another application. This works

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.