mina
mina

Reputation: 1

how to get array from unrealized data

my code-

$order[$j][1]=$q16;
<input type="hidden" name="hdnOrder" value="<?php echo htmlentities(serialize($order)); ?>">

on my next page-

$order =  array_map('mysql_real_escape_string', unserialize($_REQUEST['hdnOrder']));

it gives me the following error- Warning: array_map() [function.array-map]: Argument #2 should be an array

I want order value in array form because of-

foreach($order as $row)

Upvotes: 0

Views: 213

Answers (2)

c0rnh0li0
c0rnh0li0

Reputation: 149

You should use urldecode/urlencode instead of htmlentities.

Upvotes: 0

Pekka
Pekka

Reputation: 449395

Your problem is the htmlentities() you are doing on the data.

Use htmlspecialchars(serialize($order), ENT_QUOTES) instead and do a htmlspecialchars_decode() afterwards.

$order =  array_map('mysql_real_escape_string', 
 unserialize(htmlspecialchars_decode($_REQUEST['hdnOrder'], ENT_QUOTES)));

Upvotes: 1

Related Questions