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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:18:59+00:00 2026-05-24T02:18:59+00:00

I know similiar questions have been asked, but I’ve still been unable to resolve

  • 0

I know similiar questions have been asked, but I’ve still been unable to resolve my issue. When my view loads, I get the error below, and I know there is a value in $id.

Message: Undefined variable: id
Filename: admin/upload_form.php
Line Number: 17

Controller:

public function getEventNameById( $id ) {
            $q = $this->event_model->getEventNameById( $id );            
            echo "Event Name: ".$q."</p>";
            $data['id'] = $id;            
            $this->load->view('admin/upload_form',array('error' => ' ' ), $data);
}

View:

<body>
<div>
<?php echo $error;?>
<p>Event Image:</p>
<?php echo form_open_multipart('admin_upload/do_upload');?>

<input type="file" name="userfile" size="20" />
<br /><br />
<input type="hidden" id="iEventID" name="iEventID" value="<?php echo $id;?>" />
<input type="submit" value="upload event image" /> <input type="button" value="close" 
onclick="window.close()">

</form>
</div>
</body>

What I need to be able to do, is query information based on an ID, then pass that ID to my view, which will then pass the ID back to a different controller function for use in updating a record in my database. In other words I need to persist the ID throughout.

Any and all assistance is greatly appreciated.

  • 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-24T02:19:00+00:00Added an answer on May 24, 2026 at 2:19 am

    You’re passing the view data incorrectly:

    Your code passes 3 parameters:

    $this->load->view('admin/upload_form', array('error' => ' ' ), $data);
    //                |        1         |            2          |   3   |
    

    You should pass all data to the second parameter:

    $this->load->view('admin/upload_form', array('error' => ' ' ) + $data);
    //                |        1         |                  2             |
    

    The third param is supposed to be a boolean, whether or not to print the data directly (default false) or store it in a variable (true).

    I just used the + operator to combine the arrays, but it probably would be cleaner to use this:

    $data['error'] = ''; // Not sure why this is needed, but I assume it is
    $data['id'] = $id;   
    $this->load->view('admin/upload_form', $data);
    

    What happened was your $data array wasn’t getting passed to the view at all, hence the undefined variable.

    Reference: http://codeigniter.com/user_guide/libraries/loader.html

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

Sidebar

Related Questions

I know similiar questions have been asked before, but please bear with me as
I know similar questions have been asked before, but still things are not clear
Similar questions have been asked but I still don't know/understand the answer. When adding
I know similar questions have been asked in the past, but they still haven't
I know similar questions have been asked before, but I've tried many times and
I know similar questions have been asked, but I'm not sure about the answers
I know that similar questions have been asked before, but I am very much
I know that similar questions have been asked all over the place, but I'm
I know similar questions have been asked before but I haven't seen one where
I know similar questions have been asked many times befor, but I think this

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.