Duplicating Include

  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

I have the following functions in my install class.
PHP Code: [ Select ]
    function fstage($stage)
    {
        include_once($box_path .'install/stages/'. $stage .'.html');
        if(isset($_POST['submit']))
        {
            include_once($box_path .'install/stages/p_'. $stage .'.php');
        }
    }
 
    function install($paged = null)
    {
        $page = (isset($paged) ? $paged : (isset($_GET['page']) ? $_GET['page'] : 'database'));
       
        switch($page)
        {
            case 'database':
                $this->fstage('database');
                break;
            case 'config':
                $this->fstage('config');
                break;
            case 'administration':
                $this->fstage('administration');
                break;
            default:
                if(!$this->done_stages())
                {
                    $stage = $this->find_nstage();
                    $this->fstage($stage);
                }
                else
                {
                    die('<strong>ERROR 2:</strong> <em>The installation is complete.</em>');
                }
                break;
        }
    }
  1.     function fstage($stage)
  2.     {
  3.         include_once($box_path .'install/stages/'. $stage .'.html');
  4.         if(isset($_POST['submit']))
  5.         {
  6.             include_once($box_path .'install/stages/p_'. $stage .'.php');
  7.         }
  8.     }
  9.  
  10.     function install($paged = null)
  11.     {
  12.         $page = (isset($paged) ? $paged : (isset($_GET['page']) ? $_GET['page'] : 'database'));
  13.        
  14.         switch($page)
  15.         {
  16.             case 'database':
  17.                 $this->fstage('database');
  18.                 break;
  19.             case 'config':
  20.                 $this->fstage('config');
  21.                 break;
  22.             case 'administration':
  23.                 $this->fstage('administration');
  24.                 break;
  25.             default:
  26.                 if(!$this->done_stages())
  27.                 {
  28.                     $stage = $this->find_nstage();
  29.                     $this->fstage($stage);
  30.                 }
  31.                 else
  32.                 {
  33.                     die('<strong>ERROR 2:</strong> <em>The installation is complete.</em>');
  34.                 }
  35.                 break;
  36.         }
  37.     }

The problem with it, is that it's including the form TWICE!

If you need the whole class then let me know... thanks for the help. I don't really want to have two forms included into my installation.

[EDIT:] include_once did the trick, but I still don't know why it included the form twice the regular way. I'd still like to know why it would do such a thing.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • NagudNasorum
  • Born
  • Born
  • NagudNasorum
  • Posts: 3
  • Loc: Iasi

Post 3+ Months Ago

If you can't make it, FAKE IT!
Try to use something like that:

Code: [ Select ]
$included = false;
 
while() {
  if($included != true) {
    include_ince('you_form_page_whatever.php');
    $included = true;
  }
}
  1. $included = false;
  2.  
  3. while() {
  4.   if($included != true) {
  5.     include_ince('you_form_page_whatever.php');
  6.     $included = true;
  7.   }
  8. }
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

I figured out the problem a while ago actually and forgot to mention it.

The problem I had is that the function was named the same as the class and I had $install = new install(); and $install->install(); on my page, calling on the same function twice.

I just renamed the install function and everything works fine now.

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 57 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.