tags:

views:

78

answers:

1

Hello ,

I have this function to edit all fields that come from the form and its works fine ..

function editRow($tableName,$id)
    {

    $fieldsData = $this->db->field_data($tableName);
    $data = array();
    foreach ($fieldsData as $key => $field)
    {
      $data[ $field->name ] = $this->input->post($field->name);
    }
    $this->db->where('id', $id);
    $this->db->update($tableName, $data);

  }

now I want to add a condition for Password field , if the field is empty keep the old password , I did some thing like that :

function editRow($tableName,$id)
{
    $fieldsData = $this->db->field_data($tableName);
    $data = array();
    foreach ($fieldsData as $key => $field)
    {
        if ($data[ $field->name ] == 'password' && $this->input->post('password') == '' )  
            {
              $data[ 'password' ] => $this->input->post('hide_password'),
              //'password'        => $this->input->post('hide_password'),
            }
            else {
               $data[ $field->name ] => $this->input->post($field->name)
            }
        }
        $this->db->where('id', $id);
        $this->db->update($tableName, $data);
    }

but I get error ( Parse error: syntax error, unexpected T_DOUBLE_ARROW in ... )

Html , some thing like this :

<input type="text"  name="password"  value="">
<input type="hidden"  name="hide_password"  value="$row->$password"  />

umm , any help ?

thanks ..

+2  A: 

I don't think "=>" is a valid PHP operator. Perhaps you meant to use "=", the assignment operator, on that line?

Zach
Waw ..you are right , thank you its work now :) how I missed that !!
ahmad