bullbreed Posted March 1, 2010 Share Posted March 1, 2010 Hi Guys I'm trying (but failing) to unserialize some data in the database I have 5 image urls stored as a serialized array uploads/black.jpg uploads/white.jpg uploads/blue.jpg uploads/red.jpg uploads/pink.jpg The images associated with these urls are in the uploads folder How do I unserialize them and show them on screen. Here is my attempt (doesnt work) [syntax=php] <?php if (isset($_GET['cid'])){ $sql = "SELECT * FROM `products` WHERE `prod_cat` = '".$_GET['cid']."' "; $query = mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($query) > 0) { while ($row = mysql_fetch_assoc($query)){ $colours = unserialize($row['prod_colours']); $itemcount = count($colours); for ($i=0;$i<$itemcount;$i++) { ?> <div class="image-select"><?php echo $colours[$i]; ?></a></div> <?php } } } } ?> [/syntax] I get this notice Notice: unserialize() [function.unserialize]: Error at offset 40 of 50 bytes in C:\xampp\htdocs\folders\includes\prodcontent.php on line 24. But not sure what that is. Link to comment https://forums.phpfreaks.com/topic/193793-unserialize-data/ Share on other sites More sharing options...
GKWelding Posted March 2, 2010 Share Posted March 2, 2010 Can you post here what your serialized array looks like? I'd be able to help you more if you did. Cheers. Link to comment https://forums.phpfreaks.com/topic/193793-unserialize-data/#findComment-1020336 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.