Jump to content

help with unserialize();


gdfhghjdfghgfhf

Recommended Posts

i have an entry in my database with a lot of serialized things

 

it looks like this:

a:2:{i:1;s:6:"blablablabla1";i:2;s:6:"blablablabla2";}

 

i'm trying to make it more human-readable, and i would also make each word linkable

 

so instead of the serialized thing it would look like this:

<a href="blablablabla1.php">blablablabla1</a><br>
<a href="blablablabla2.php">blablablabla2</a><br>

 

but i can't even manage to unserialize it :(

 

i tryed with this:

mysql_connect($server, $user, $password) or die(mysql_error());

mysql_select_db($database) or die(mysql_error());

 

$query = "SELECT * FROM calendarcustomfield";

$res = mysql_query($query) or die(mysql_error()); 

 

while($row = mysql_fetch_array($res)) {

$options = $row["options"];

echo unserialize($options);

}

 

but it always returns "Array" nothing else... it just displays the word Array

 

could someone help me please?

Link to comment
https://forums.phpfreaks.com/topic/99743-help-with-unserialize/
Share on other sites

mysql_connect($server, $user, $password) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());

$query = "SELECT * FROM calendarcustomfield"; 
$res = mysql_query($query) or die(mysql_error());  

while($row = mysql_fetch_array($res)) { 
$options = $row["options"];
print_r(unserialize($options));
}

use print_r to print array variables, see if it helps, :)

Link to comment
https://forums.phpfreaks.com/topic/99743-help-with-unserialize/#findComment-510176
Share on other sites

this is called an array. you can use arrays like so:

 

$array['array_key'] = "value";

foreach($array As $array_item){
echo($array_item);
}

 

to incorporate this you could try:

 

mysql_connect($server, $user, $password) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());

$query = "SELECT * FROM calendarcustomfield"; 
$res = mysql_query($query) or die(mysql_error());  

while($row = mysql_fetch_array($res)) { 
   $options = unserialize($row["options"]);
   
   foreach($options As $option){
      echo("<a href=\"$option.php\">$option</a><br />\n");
   }
}

 

hope this helps ;)

Link to comment
https://forums.phpfreaks.com/topic/99743-help-with-unserialize/#findComment-510185
Share on other sites

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.