Jump to content

need help with serialize() again


Guest

Recommended Posts

here's what i'm trying to do

 

i have a field in my database (options in table quebec_calendarcustomfield) used in vbulletin for calendar custom fields. I want to allow a group of users to add and delete fields...

 

So now i'm trying to make a page where my users are able to delete a field.

 

All fields are serialized and stored in quebec_calendarcustomfield WHERE calendarcustomfieldid = '1'

 

so i tryed to unserialize it, do a str_replace to delete the field i want, and serialize it back....

 

but i'm stuck at serializing back, i can't find out how to serialize the whole array

 

include("db.php");
$query = "SELECT options FROM quebec_calendarcustomfield WHERE calendarcustomfieldid = '1'";
$res = mysql_query($query) or die(mysql_error());  
while($row = mysql_fetch_array($res)) { 
$a = $row["options"];

$unseri = unserialize($a);

foreach($unseri as $value)
{
$hmm = str_replace("$legroupe", "", "$value");
   echo $hmm;
} 

echo "<br><br>";
$uhh = serialize($value);
echo $uhh;

$cc = mysql_real_escape_string($uhh);
$zxc = "UPDATE quebec_calendarcustomfield SET options = '$uhh' WHERE calendarcustomfieldid = '1'";
$res = mysql_query($zxc) or die(mysql_error());  
}

 

$legroupe is a defined $_GET value and it contains the line i want to delete

 

$a = $row["options"];  is the serialized array of ALL the fields, including the one i want to delete

Link to comment
https://forums.phpfreaks.com/topic/100427-need-help-with-serialize-again/
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.