Welcome Guest, Not a member yet? Register   Sign In
[HELP NEEDED] array serialization and inserting into database
#3

[eluser]M52 Studios[/eluser]
Here's my entire function and the results that are printed to the page, along with database insertions:

Code:
function process_part1()
    {
        /* legal_name - required
         * display_name
         * live_support - yes/no
         * reservation_phone - required
         * website
         * insured_vehicles - required
         * start_year - required
         * association - yes/no
         */
        
        $temp_data = array();
        
        /*
         * assign $_POST values to proper variables
         */
        $temp_data['legal_name'] = (isset($_POST['legal_name'])) ? $_POST['legal_name'] : NULL;
        //$this->legal_name = (isset($_POST['legal_name'])) ? $_POST['legal_name'] : NULL;
        //echo $this->legal_name . "<br />";
        $temp_data['display_name'] = (isset($_POST['display_name'])) ? $_POST['display_name'] : NULL;
        //echo $this->display_name . "<br />";
        $temp_data['live_support'] = (isset($_POST['live_support'])) ? $_POST['live_support'] : NULL;
        //echo $this->live_support . "<br />";
        $temp_data['reservation_phone'] = (isset($_POST['reservation_phone'])) ? $_POST['reservation_phone'] : NULL;
        //echo $this->reservation_phone . "<br />";
        $temp_data['website'] = (isset($_POST['website'])) ? $_POST['website'] : NULL;
        //echo $this->website . "<br />";
        $temp_data['insured_vehicles'] = (isset($_POST['insured_vehicles'])) ? $_POST['insured_vehicles'] : NULL;
        //echo $this->insured_vehicles . "<br />";
        $temp_data['start_year'] = (isset($_POST['start_year'])) ? $_POST['start_year'] : NULL;
        //echo $this->start_year . "<br />";
        $temp_data['association'] = (isset($_POST['association'])) ? $_POST['association'] : NULL;
        //echo $this->association . "<br />";
        $temp_data['short_description'] = (isset($_POST['description'])) ? $_POST['description'] : NULL;
        //echo $this->short_description . "<br />";
        
        $str = serialize($temp_data);
        
        print var_dump($str) . "<br /><br />";
        
        
        print $str . "<br /><br />";
        
        $data = array('part_1' => $str, 'part_2' => NULL, 'part_3' => NULL);
        
        print_r($data);
        print "<br /><br />";
        
        $this->db->insert('temp_form_data', $data);
        
        $id = $this->db->insert_id();
        
        return $id;
        
    } /* END process_part1*/

HERE'S THE OUTPUT FROM ABOVE

Code:
string(331) "a:9:{s:10:"legal_name";s:10:"legal name";s:12:"display_name";s:11:"public name";s:12:"live_support";s:2:"No";s:17:"reservation_phone";s:9:"123456789";s:7:"website";s:11:"www.www.com";s:16:"insured_vehicles";s:1:"6";s:10:"start_year";s:4:"1986";s:11:"association";s:2:"No";s:17:"short_description";s:25:"short company description";}"

a:9:{s:10:"legal_name";s:10:"legal name";s:12:"display_name";s:11:"public name";s:12:"live_support";s:2:"No";s:17:"reservation_phone";s:9:"123456789";s:7:"website";s:11:"www.www.com";s:16:"insured_vehicles";s:1:"6";s:10:"start_year";s:4:"1986";s:11:"association";s:2:"No";s:17:"short_description";s:25:"short company description";}

Array ( [part_1] => a:9:{s:10:"legal_name";s:10:"legal name";s:12:"display_name";s:11:"public name";s:12:"live_support";s:2:"No";s:17:"reservation_phone";s:9:"123456789";s:7:"website";s:11:"www.www.com";s:16:"insured_vehicles";s:1:"6";s:10:"start_year";s:4:"1986";s:11:"association";s:2:"No";s:17:"short_description";s:25:"short company description";} [part_2] => [part_3] => )

AND - here are the two entries that I am getting in the database:

Code:
[6] - a:9:{s:10:"legal_name";s:10:"legal name";s:12:"display_name";s:11:"public name";s:12:"live_support";s:2:"No";s:17:"reservation_phone";s:9:"123456789";s:7:"website";s:11:"www.www.com";s:16:"insured_vehicles";s:1:"6";s:10:"start_year";s:4:"1986";s:11:"association";s:2:"No";s:17:"short_description";s:25:"short company description";}    NULL    NULL
[7] - a:9{s:10:"legal_name";N;s:12:"display_name";N;s:12:"live_support";N;s:17:"reservation_phone";N;s:7:"website";N;s:16:"insured_vehicles";N;s:10:"start_year";N;s:11:"association";N;s:17:"short_description";N;}

See how the second one is a lot shorter because all the "variables" are there, but no values associated with them?

When I try to update part_2, and part_3 from similar functions, all I get are "no value" serialized arrays.

What else can I do to troubleshoot? I've tried using $_SESSIONS to keep track of all of this, but they mysteriously lose values after going through more than one page. I had a post regarding that one earlier.

Thanks guys, any help, at all would be much appreciated!!!!


Messages In This Thread
[HELP NEEDED] array serialization and inserting into database - by El Forum - 12-20-2010, 08:51 AM



Theme © iAndrew 2016 - Forum software by © MyBB