salman233 Posted August 20, 2011 Share Posted August 20, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/245278-need-help-with-unserialize/ Share on other sites More sharing options...
trq Posted August 21, 2011 Share Posted August 21, 2011 Why are you storing serialized data in the database in the first place? Quote Link to comment https://forums.phpfreaks.com/topic/245278-need-help-with-unserialize/#findComment-1259985 Share on other sites More sharing options...
salman233 Posted December 1, 2011 Author Share Posted December 1, 2011 what,s the plan then? Quote Link to comment https://forums.phpfreaks.com/topic/245278-need-help-with-unserialize/#findComment-1292882 Share on other sites More sharing options...
scootstah Posted December 1, 2011 Share Posted December 1, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/245278-need-help-with-unserialize/#findComment-1292898 Share on other sites More sharing options...
MasterACE14 Posted December 1, 2011 Share Posted December 1, 2011 if you're trying to serialize the array just to make the filtering process quicker, that's not the way to go about it. You're over complicating a simple problem. Quote Link to comment https://forums.phpfreaks.com/topic/245278-need-help-with-unserialize/#findComment-1292900 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.