Jump to content

need help with serialize() again


gdfhghjdfghgfhf

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.