help with serialize & unserialize
Please help me to find error and fix this php file. I'm a php newbie.
This is a php file allowed me to edit the database. I was able to pull it form the database, but when I submit it... the clues field got empty..
I know there's something wrong with the code, but dont know how to fix it...
Please help ..
Thanks
I know there's something wrong with this code below, but Don't know how to fix it...
Please help me to find error and fix this php file. I'm a php newbie.
This is a php file allowed me to edit the database. I was able to pull it form the database, but when I submit it... the clues field got empty..
I know there's something wrong with the code, but dont know how to fix it...
Please help ..
Thanks
PHP:
<?
if($_REQUEST['action'] == "edit")
{
if (!isset($_POST["submit"]))
{
$id = $_REQUEST["id"];
$sql = "SELECT * FROM taboo WHERE id=$id";
$result = mysql_query($sql);
$r = mysql_fetch_array($result);
list($c1, $c2, $c3, $c4, $c5) = unserialize($r['clues']);
?>
<form action="index.php" method="post">
<input type=hidden name="id" value="<?php echo $r["id"] ?>">
Link: <input type="text" name="word" style="font-size: 10pt; font-weight: bold" size="41" VALUE="<? echo $r["word"] ?>" autocomplete="off" /><br /><br />
Clue 1: <input type="text" name="clues" style="font-size: 10pt; font-weight: bold" size="41" VALUE="<? echo $c1 ?>" autocomplete="off" /><br /><br />
Clue 1: <input type="text" name="clues" style="font-size: 10pt; font-weight: bold" size="41" VALUE="<? echo $c2 ?>" autocomplete="off" /><br /><br />
Clue 1: <input type="text" name="clues" style="font-size: 10pt; font-weight: bold" size="41" VALUE="<? echo $c3 ?>" autocomplete="off" /><br /><br />
Clue 1: <input type="text" name="clues" style="font-size: 10pt; font-weight: bold" size="41" VALUE="<? echo $c4 ?>" autocomplete="off" /><br /><br />
Clue 1: <input type="text" name="clues" style="font-size: 10pt; font-weight: bold" size="41" VALUE="<? echo $c5 ?>" autocomplete="off" /><br /><br />
Live: <input type="text" name="live" style="font-size: 10pt; font-weight: bold" size="41" VALUE="<? echo $r["live"] ?>" autocomplete="off" /><br />
<input type="hidden" name="action" value="edit">
<input type="submit" name="submit" value="submit">
</form>
<? }
if ($_POST["submit"])
{
$word = $_POST["word"];
$clues = $_POST["clues"];
$live = $_POST["live"];
$id = $_POST["id"];
list($c1, $c2, $c3, $c4, $c5) = unserialize($r['clues']);
//replace links with your table name above
$result = mysql_query("UPDATE taboo SET word='$word', clues='$clues', live='$live' WHERE id=$id")or die(mysql_error());
//header("location: index.php");
echo "Thank you! Information updated.";
}
}
?>
I know there's something wrong with this code below, but Don't know how to fix it...
PHP:
<? }
if ($_POST["submit"])
{
$word = $_POST["word"];
$clues = $_POST["clues"];
$live = $_POST["live"];
$id = $_POST["id"];
list($c1, $c2, $c3, $c4, $c5) = unserialize($r['clues']);
//replace links with your table name above
$result = mysql_query("UPDATE taboo SET word='$word', clues='$clues', live='$live' WHERE id=$id")or die(mysql_error());
//header("location: index.php");
echo "Thank you! Information updated.";
}
}
?>
Last edited:










