narjis Posted March 3, 2011 Share Posted March 3, 2011 I want to save class property values and want to write these in the database after being called from another function. class model{ public $dbh; public $user_arr=array('username','password','email','location','interest','homepage'); public function insert_data() { $sql = "INSERT INTO account VALUES ('" .$user_info['username']."','".$user_info['password'] ."','".$user_info['email']."', 'user','".$user_info['location']."','".$user_info['interests'] ."','".$user_info['homepage']."')"; //if(isset($data)) echo $sql; } public function data_approoved($user){ //$user_info = new array(); $user_arr['username'] = $user['username']; $user_arr['password'] = $user['password']; $user_arr['email'] = $user['email']; $user_arr['location'] = $user['location']; $user_info['interests'] = $user['interests']; $user_info['homepage'] = $user['homepage']; Model::insert_data(); } } }//class ended The approoved_data function is supposed to set the values of $user_info array which should be later on stored in database. Please somebody help me. Link to comment https://forums.phpfreaks.com/topic/229482-saving-property-values-in-an-an-object/ Share on other sites More sharing options...
Muddy_Funster Posted March 3, 2011 Share Posted March 3, 2011 what array are you working with? $user_arr[] or $user_info[]?. and why are you not just working with the $user[] array that you are copying the information from in the first place? Link to comment https://forums.phpfreaks.com/topic/229482-saving-property-values-in-an-an-object/#findComment-1182318 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.