Welcome Guest, Not a member yet? Register   Sign In
Kindof a php question.. but..re: adding to arrays
#1

[eluser]octavianmh[/eluser]
Guys-

So I'm working on a form which updates a database..thing is I'm trying to make this relatively generic, and the form — depending on what's being edited — can have a variable number of fields. Getting the form to work has been easy-peasy...getting it into the model to execute the update has been harder.

Here's an excerpt:

Code:
$editData = array();

    if ($this->input->post('Shortcode')) { array_push($editData['Shortcode'], $this->input->post('Shortcode')); }
    if ($this->input->post('ListName')) { array_push($editData['ListName'], $this->input->post('ListName')); }
    if ($this->input->post('InjectPassword')) { array_push($editData['InjectPassword'], $this->input->post('InjectPassword')); }
    if ($this->input->post('APIusername')) { array_push($editData['APIusername'], $this->input->post('APIusername')); }    

    $this->service->editService($this->input->post('service_id'), $editData);

But I get this error:

Message: array_push() [function.array-push]: First argument should be an array

While I THINK i'm following the instructionf from: http://us2.php.net/array_push

Down the page a bit they show the method for inserting key=>value pairs into an array_push.

Anyway, probably something dumb, any ideas?


Messages In This Thread
Kindof a php question.. but..re: adding to arrays - by El Forum - 04-22-2009, 06:50 PM
Kindof a php question.. but..re: adding to arrays - by El Forum - 04-22-2009, 07:44 PM
Kindof a php question.. but..re: adding to arrays - by El Forum - 04-22-2009, 11:37 PM
Kindof a php question.. but..re: adding to arrays - by El Forum - 04-23-2009, 06:14 AM
Kindof a php question.. but..re: adding to arrays - by El Forum - 04-23-2009, 06:49 AM
Kindof a php question.. but..re: adding to arrays - by El Forum - 04-23-2009, 06:50 AM
Kindof a php question.. but..re: adding to arrays - by El Forum - 04-23-2009, 06:56 AM



Theme © iAndrew 2016 - Forum software by © MyBB