Jump to content

need help with unserialize


salman233

Recommended Posts

guys this is my code

<?php

include("header.php");

include("conn.php");

?>

<html>

<head>

</head>

<body>

<table border="1" cellpadding="0" cellspacing="0" align="center">

<tr>

<td>Please Enter the Amount</td>

<td valign="top" align="left" width="200">

<form action="next.php" method="post">

<input name="amount" value="1" size="7">

</td>

<tr>

<td>From:</td>

<td valign="top" align="left" width="200">

<?php

 

$real= array (

'USD'=>1,

'PAK'=>1.6323,

'GBP'=>1.02544

);

 

 

$abc= mysql_real_escape_string( serialize($real) );

//$ddsr=unserialize($abc);

 

 

//$abc= implode(",",$real);

//echo $abc;

$from= array('Dollars','Rupees','Pounds');

$length = count($from);

//$dbs=implode(",",$from);

 

 

 

$dql = "INSERT INTO countrytype (`ID`,`fromcountry`,`tocountry`) VALUES ('','".$abc."','".$abc."')";

mysql_query($dql) or die(mysql_error());

 

$to= array('Dollars','Rupees','Pounds');

$to=str_replace("","",$to);

?>

<input type="hidden" name="h1" value="<?php echo $length;?>">

<select>

<?PHP

$dgd= "SELECT * FROM countrytype GROUP BY ID";

$aws= mysql_query($dgd) or die(mysql_error());

while($row=mysql_fetch_array($aws))

{

$des=stripslashes($row['fromcountry']);

$dsw=unserialize($des);

//$des=explode("",$row['fromcountry']);

//var_dump($dsw);

//echo "<td>".$row['ID']."<td>";

//echo "<td>".$dsw."<td>";

$k=1;

foreach($dsw as $key=>$value)

{

echo "<option name='ad[]' value='$value'>$value</option>";

//print_r(array_keys($des));

 

$k++;

 

}

}

//$sss=explode("",$row['fromcountry']);

//echo $sss;

 

?>

</select>

<select>

<?php

$i=0;

$k=1;

foreach($from as $abd => $value)

{

 

   

   

echo  "<option name='ar[]' value='$value' >$value</option>";

      $k++;

 

}

 

 

?></td></tr></select>

 

<td>To: </td><td><select>

<?php

foreach($to as $abd => $value)

{

$i++;

 

echo "<option id='i' >$value</option>";

 

}

 

 

?>

</select>

<input type="submit" name="sub" value="Convert!"/>

</form>

</td>

</tr>

 

 

</tr>

 

 

 

</table>

 

</body>

</html>

 

serilization works but when i fetch it from database and unserialize it nothing works

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

  • 3 months later...

Please use code tags.

 

Have you compared the database result beside the serialized data before it went into the database? What is different about it?

 

I'm guessing you are either exceeding the character length or you have magic_quotes on.

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.