Jump to content

Multi Dimensional array - MySQL


williamZanelli

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.