What's Broken?

I changed something awhile back & I guess I didn't test it. Now I can't fix whatever I changed?

Trying to insert a record.
I get error
Quote:Message: Undefined index: addupdate
Filename: controllers/outage.php

NOTE: If I uncomment the redirect I'll see the error & the page redirects quickly with the update inserted into the DB. But why the error?

function addupdate() {
      //Submit an update to the 'UPDATES' table.
      $id = $this->uri->segment(3);
      $this->outage_model->addupdate($_POST['addupdate'], $_POST);
      $link = array('outage/editoutage', $_POST['outageid']);

function addupdate($id, $data)
    // Update one outage record
      $this->db->where('outageid', $id);
      $this->db->insert('updates', $data);

The only line in your example that contains that index is
$this->outage_model->addupdate($_POST['addupdate'], $_POST);

Since you don't tell us where this error occured, I assume that $_POST doesn't contain a field called 'addupdate'.

Can you post the form?

Sorry WanWizard, was reading it when you posted. I agree though.

Oh wow. I really don't understand things I think.

'addupdate' is the name of my function in the model.
echo form_open('outage/addupdate');
    echo form_hidden('outageid', $outage[0]->outageid);?>
    <table id="outageform">
        <col />
        <tr><td>Add Update</td><td>&lt;?php echo form_textarea($update_textarea);?&gt;</td></tr>
        <tr><td>          </td><td>&lt;?php echo form_submit('', 'Add an Update');?&gt;</td></tr>
    &lt;?php echo form_close(); //End form to add updates


But the error said "Undefined index". Which has nothing to do with method names, an index is an array index. And as $_POST is an array, and 'addupdate' in key in that array that you reference, it is my assumption that that like is causing the error.

Thanks. Figuring things out now, but I have a new problem.

In several Form Submits I get the following error just before the redirect, but all data makes it into the DB.

Quote:Message: preg_match() expects parameter 2 to be string, array given
Filename: helpers/url_helper.php
Line Number: 532

I'd really like to understand this error.

If this is your level of understanding, perhaps you should consider some additional development/PHP training?

The message is very clear. You have called a function defined in the URL helper with the wrong type of parameter.
Simply looking in the file mentioned, at the line mentioned, would have told you want you did wrong.
I checked, and it's pretty obvious, but I leave it to you as a training excercise. Wink

I'm an idiot.
I understood what the error was saying, but couldn't figure out why this had shown up 'all of the sudden'. Think I copy/pasted something awhile ago & just didn't check it.

Sleep helps.

$link = 'outage/editoutage/' . $_POST['outageid'];


I solved that problem with an espresso machine on my desk. Smile

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.