Jump to content

anuradhu

Members
  • Posts

    16
  • Joined

  • Last visited

    Never

Everything posted by anuradhu

  1. Wow !! thanks a ton !! The problem is exactly that - comp->pvc is string(5) "EMPTY"
  2. Here is the code if ($comp -> pvc[$real_bas_id]['name']!="") continue; $tpl -> setVariable(array( 'BAS' => $real_bas_info['name'], 'BAS_ID'=> $real_bas_id, )); and here is what i see when i try to dump the REAL_BAS_ID array array(23) { [7]=> array(1) { ["name"]=> string(11) "value" } [14]=> array(1) { ["name"]=> string(12) "value" } [23]=> array(1) { ["name"]=> string(13) "value" } [1]=> array(1) { ["name"]=> string(17) "value" } [20]=> array(1) { ["name"]=> string(18) "value" } [6]=> array(1) { ["name"]=> string(15) "value" } [13]=> array(1) { ["name"]=> string(16) "value" } [10]=> array(1) { ["name"]=> string(11) "value" } [19]=> array(1) { ["name"]=> string(12) "value" } [9]=> array(1) { ["name"]=> string(6) "value" } [17]=> array(1) { ["name"]=> string(7) "value" } [3]=> array(1) { ["name"]=> string(9) "value" } [21]=> array(1) { ["name"]=> string(10) "value" } [8]=> array(1) { ["name"]=> string(10) "value" } [15]=> array(1) { ["name"]=> string(11) "value" } [4]=> array(1) { ["name"]=> string( "value" } [16]=> array(1) { ["name"]=> string(9) "value" } [5]=> array(1) { ["name"]=> string(7) "value } [12]=> array(1) { ["name"]=> string( "value" } [22]=> array(1) { ["name"]=> string(9) "value" } [11]=> array(1) { ["name"]=> string(4) "value" } [2]=> array(1) { ["name"]=> string(7) "value" } [18]=> array(1) { ["name"]=> string( "value" } }
  3. Could someone here explain me the reason for this error in detail..... FYI - i am just more than a fresher in PHP..... Fatal error: Cannot use string offset as an array
  4. Thanks for all your help!! The last post helped me resolve the issue.
  5. When i make the code like this $this -> $what = addslashes($value); I receive the following error: Fatal error: Cannot access empty property in /export/web/application/engine/employee.class on line 223
  6. Hi - thanks for the reply... I am almost sure that the code i have placed here is causing the problem since this is the flow - i tryed to insert manual breakpoints and figured out the flow.. The query should actually be like this, i.e i have changed the value of the employee_firstname in the form UPDATE employee SET last_change=now(),employee_firstname = 'newvalue',updated='0' WHERE id='143525' where as it is like this ---- the values from the form are placed into the object and then the object is looped to frame the query.. UPDATE employee SET last_change=now(),updated='0' WHERE id='143525'
  7. I added this code and I see a list of NOTICE items displayed. When i try to hardcode the Update query, it works without any problem and even with this dynamically generated query the only problem is that the variable values are not populated; the Update query gets executed just with the initial query.
  8. thank you i did this.... but - do you still have any other clue for my problem? pls...
  9. Ah - I missed to mention this I am using the below code to generate the values into a local scope from the FORM POST - to cope with the migration to PHP 5. foreach ($_REQUEST as $field => $value) { $$field = $value; }
  10. Ok- i have made the changes you suggested - but still my problem is not yet resolved
  11. Hi anupamsaha i tried your change - but eventually it just assigns the variable name to the $this->this_field;
  12. Sorry -here is teh code.... class teleworking_employee{ var $lang = 'nl'; var $error = ''; var $error_nr = ''; var $dbh = ''; var $employee_id = ''; var $employee_name = ''; var $employee_firstname = ''; var $company_id = ''; var $project_id = ''; var $employee_fields = array( 'id', 'last_change','first_entry', 'company_id','project_id', 'name','firstname', 'phone', 'comment', 'updated'); /** * constructor: * set the language * @param language, database handle, company_id[,project_id] * @return void **/ function teleworking_employee($lang,$dbh,$company_id,$project_id=''){ $this -> lang = $lang; $this -> dbh = $dbh; $this -> company_id = $company_id; if($project_id != ''){ $this -> project_id = $project_id; } } function get_employee_info($employee_id,$company_id = ''){ if(!$company_id){ $company_id = $this -> company_id; } $query = "SELECT id, last_change, first_entry, company_id, project_id, name, firstname, phone, deleted, comment, updated, billed FROM employee WHERE company_id='$company_id' AND id='$employee_id'"; if($this -> project_id != ''){ $query .= " AND project_id='".$this -> project_id."'"; } //print $query; #$get = mysql_query($query,$this -> dbh); $get = mysql_query($query); if(mysql_num_rows($get)){ $result = mysql_fetch_object($get); foreach($this -> employee_fields as $key => $field){ if($field == 'id'){ $field = 'project_'.$field; } $this_field = 'employee_'.$field; $this -> $this_field = stripslashes($result -> $field); } return TRUE; }else{ $this -> error .= 'no employee found'; $this -> error_nr = ''; return FALSE; } } function change_employee_info($employee_id){ $query = 'UPDATE '; return $this -> do_query($query,$employee_id); } function set_value($what,$value){ if($what == 'employee_phone'){ $value = preg_replace('/[^\d]/','',$value); } $this -> what = addslashes($value); } } }
  13. The class is a very huge one -i have included the member variable declaration and the methods used in my code....here class teleworking_employee{ var $lang = 'nl'; var $error = ''; var $error_nr = ''; var $dbh = ''; var $employee_id = ''; var $employee_name = ''; var $employee_firstname = ''; var $company_id = ''; var $project_id = ''; var $employee_fields = array( 'id', 'last_change','first_entry', 'company_id','project_id', 'name','firstname', 'phone', 'comment', 'updated'); /** * constructor: * set the language * @param language, database handle, company_id[,project_id] * @return void **/ function teleworking_employee($lang,$dbh,$company_id,$project_id=''){ $this -> lang = $lang; $this -> dbh = $dbh; $this -> company_id = $company_id; if($project_id != ''){ $this -> project_id = $project_id; } } function get_employee_info($employee_id,$company_id = ''){ if(!$company_id){ $company_id = $this -> company_id; } $query = "SELECT id, last_change, first_entry, company_id, project_id, name, firstname, phone, deleted, comment, updated, billed FROM employee WHERE company_id='$company_id' AND id='$employee_id'"; if($this -> project_id != ''){ $query .= " AND project_id='".$this -> project_id."'"; } //print $query; #$get = mysql_query($query,$this -> dbh); $get = mysql_query($query); if(mysql_num_rows($get)){ $result = mysql_fetch_object($get); foreach($this -> employee_fields as $key => $field){ if($field == 'id'){ $field = 'project_'.$field; } $this_field = 'employee_'.$field; $this -> $this_field = stripslashes($result -> $field); } return TRUE; }else{ $this -> error .= 'no employee found'; $this -> error_nr = ''; return FALSE; } } function change_employee_info($employee_id){ $query = 'UPDATE '; return $this -> do_query($query,$employee_id); } function set_value($what,$value){ if($what == 'employee_phone'){ $value = preg_replace('/[^\d]/','',$value); } $this -> what = addslashes($value); } } }
  14. Thank you all... i have tried changing this -- $field=$this->this_field; this returns me empty string.
  15. This is the code of the that manipulates the data from the form ----------------------------------------------------------------------------------------------------------------------------------------- if($empl = new tel_employee('en',$dbh,$company_id)){ //get employee info $empl->get_employee_info($employee_id,$company_id); //change the info for that employee_id in the db foreach($employee_fields as $key => $field){ $post_field=$field; if($field == 'id'){ $field = 'employee_id'; } $value = $$field; $new_field = 'employee_'.$field; $empl -> set_value($new_field,$value); } #change the info for employee if(!($empl -> change_employee_info($employee_id))){ error('change employee '.$empl -> error); }else{ echo 'Success'; } } } ----------------------------------------------------------------------------------------------------------------------------------------- This is code which forms the query for update ----------------------------------------------------------------------------------------------------------------------------------------- function do_query($query,$update = 0){ $query .= "employee SET "; //look if any of the fields have a value and change them if so foreach($this -> employee_fields as $key => $field){ $this_field = 'employee_'.$field; if($this -> $this_field != ''){ $query .= "$field='".$this -> $this_field."',"; } } if($update){ //we are updating an existing employee $query .= " WHERE id='$update'"; } else{ //adding a new employee, set the initial date $query .= ",first_entry=now(),split_plan_new_status = '1'"; } if(mysql_query($query)){ $this -> employee_id = $update; return $update; } else{ $this -> error .= 'something wrong with the query : '.$query.'<br>'.mysql_error(); $this -> error_nr = ''; return FALSE; } } -----------------------------------------------------------------------------------------------------------------------------------------
  16. I am working on a migration project; i am not an expert in PHP though ! I have a class and an object of the class is used to display the values in the form controls and on submit of the form the object is updated with new values from the form and then a method in the class is invoked which performs the update query. $field=$this -> $this_field; The above code works perfect in PHP 4 but after moving the new machine with PHP 5 it doesnot update. Any help would be greatly appreciated.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.