williamZanelli Posted July 2, 2008 Share Posted July 2, 2008 Hi guys, I have a multi-dimensional array that I would like to store and then later from my database [mySQL] In Pseudo code 1. Create the multi dimensional array 2. Serialize the array - I print the array using print_r($array); and it prints out the correct result. 3. Add to my Query and update the database The array is stored as 'Array' [this is what appears in my DB] - when I retrieve the value and unserilaize, and do print_r($retrievedArray) It prints 'Array' and not the values that where in the array - As expected Have I missed a step? Thnaks in advance for your help, Will. Link to comment https://forums.phpfreaks.com/topic/112929-multi-dimensional-array-mysql/ Share on other sites More sharing options...
DarkWater Posted July 2, 2008 Share Posted July 2, 2008 We'd prefer real code over pseudo-code, thanks. Link to comment https://forums.phpfreaks.com/topic/112929-multi-dimensional-array-mysql/#findComment-580072 Share on other sites More sharing options...
PFMaBiSmAd Posted July 2, 2008 Share Posted July 2, 2008 Somewhere in step 2 or step 3 your code is not doing what you think it is. Link to comment https://forums.phpfreaks.com/topic/112929-multi-dimensional-array-mysql/#findComment-580084 Share on other sites More sharing options...
williamZanelli Posted July 2, 2008 Author Share Posted July 2, 2008 Right, here's the code which stores the array. print_r($field1_Array);//unserlised array printed - fine serialize($field1_Array); //update DB echo("Serlised array printed next<br/>"); print_r($field1_Array); $query_array = "UPDATE `links` SET `field1` = " .$field1_Array . " WHERE `add_url` = '". get_val($item, $MyArray['l_url']) ."' AND `category` != " . $semoirs->sm_category ; $db->query($query_array); When I retrieve I do the simple print_r($array); And it prints out 'Array' - and none of the values inside the array. Link to comment https://forums.phpfreaks.com/topic/112929-multi-dimensional-array-mysql/#findComment-580097 Share on other sites More sharing options...
PFMaBiSmAd Posted July 2, 2008 Share Posted July 2, 2008 serialize() returns the serialized data as a string that you would need to use in your UPDATE query. Your code is not assigning the results returned by that function to anything. Link to comment https://forums.phpfreaks.com/topic/112929-multi-dimensional-array-mysql/#findComment-580111 Share on other sites More sharing options...
williamZanelli Posted July 3, 2008 Author Share Posted July 3, 2008 Thanks PFMaBiSmAd - you're spot on Link to comment https://forums.phpfreaks.com/topic/112929-multi-dimensional-array-mysql/#findComment-580965 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.