[56K WARN] lost $id variable in $_POST
Posted: Tue Jul 31, 2007 5:17 pm
I am trying to get some radio buttons to work, but before I even got into the logic of radio buttons I ran into a snag with my $id variable not being avaiable for the whole page [speifically - the top $_POST portion of the page].
Below is a condensed version of my page code. There is are two variables passed to this page from the previous page: $id and $imageid
The commented portion is my radio button code, that is where I need the $id variable - in the WHERE mysql statement.
The $id tag seems to work everywhere else. What am I missing? Is there an "eregi (left-brain && hip-check)" function I need to study?
.
Below is a condensed version of my page code. There is are two variables passed to this page from the previous page: $id and $imageid
Code: Select all
<html>
<head>
<title>Untitled 3</title>
</head>
<body>
<?php
if (isset($_POST['editimage'])):
$imageresorder = $_POST['imageresorder'];
$imagerescaption = $_POST['imagerescaption'];
$imageid = $_POST['imageid'];
$sqlupdate = "UPDATE image_res SET
image_res_order='$imageresorder',
image_res_caption='$imagerescaption'
WHERE image_id='$imageid'";
if (@mysql_query($sqlupdate)) {
echo "Residential IMAGE updated!";
} else {
echo "Error UPDATING database " . mysql_error() . "Call webmaster";
}
// $setfeaturepic = "UPDATE residential SET
// res_feature_pic='$imageid',
// res_id='$id'
// WHERE res_id='$id'";
// if (!mysql_query($setfeaturepic)) {
// echo ("<p>Error UPDATING Feature Picture!"
// . $imageid . "Call webmaster");
// }
?>
<?php
else:
$id = $_GET['id'];
$imageget = @mysql_query("SELECT
image_id,
image_res_id,
image_res_order,
image_res_caption
FROM image_res, residential
WHERE image_res_id='$id' AND image_id='$imageid'");
if (!$imageget) {
echo("Error SELECTING data from database!" . mysql_error() . "Call webmaster");
exit();
}
while ($imgarray = mysql_fetch_array($imageget)) {
$imageid = htmlspecialchars($imgarray["image_id"]);
$imageresorder = htmlspecialchars($imgarray["image_res_order"]);
$imagerescaption = htmlspecialchars($imgarray["image_res_caption"]);
}
?>
<?php endif; ?>
<form action='<?php echo $_SERVER[PHP_SELF];?>' method='post'>
<table width='300' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='150' align='left' valign='top'>
<span class='caption_cap'>Display Order</span><br>
<input name='imageresorder' class='body01' size='3' maxlength='3' value='<?php echo $imageresorder;?>'><br>
</td>
<td width='150' align='left' valign='top'><span class='caption_cap'>Feature Picture</span><br>
<input name='featurepic' type='radio' value='<?php $image_res_id;?>' ><span class='caption_cap'>yes</span>
<input name='featurepic' type='radio' value='' checked='' ><span class='caption_cap'>no</span>
</td>
</tr>
</table>
<input name='imageid' type='hidden' value='<?php echo $imageid;?>' >
<span class='caption_cap'>Picture Caption</span><br>
<input name='imagerescaption' class='body01' size='36' maxlength='64' value='<?php echo $imagerescaption;?>'>
<br>
<div align='center'><input type='submit' name='editimage' class='body01' value=' SAVE '></div>
</form>
<?php
$resselect = @mysql_query("SELECT
res_street01,
res_city,
FROM residential WHERE res_id='$id'");
if (!$resselect) {
echo("Error selecting RESIDENTIAL data from database!" . mysql_error() . "Call webmaster");
exit();
}
while ($resarray = mysql_fetch_array($resselect)) {
$resstreet01 = htmlspecialchars($resarray["res_street01"]);
$rescity = htmlspecialchars($resarray["res_city"]);
}
?>
<div align="center"><span class="caption_cap">Record Id <?php echo $id; ?></span></div>
<hr align='center' width='450' size='1' noshade>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
<tr><td align="left" width="200"valign="top">
<span class="listing01">
<strong><?php echo $restype ;?></strong><br>
<?php echo $resstreet01 ;?><br>
<?php echo $rescity ;?></span>
</td>
</tr>
</table><br>
<?php
$imgselect = @mysql_query("SELECT
image_id,
image_res_order,
image_res_caption,
FROM image_res
WHERE image_res_id='$id' ORDER by image_res_order");
if (!$imgselect) {
echo ("Error SELECTING data from database!" . mysql_error() . "Call webmaster");
exit();
}
while ($imgarray = mysql_fetch_array($imgselect)) {
$imageresorder = htmlspecialchars($imgarray["image_res_order"]);
$imagerescaption = htmlspecialchars($imgarray["image_res_caption"]);
echo "<table width='340' align='center' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='170'><span class='body01'><strong>$imageresorder </strong></span>
<span class='caption_cap'>Display Order</span></td>
<td width='170' align='left'><br><span class='caption_cap'>Picture Caption</span><br>
<span class='body01'><strong>$imagerescaption</strong></span></td>
</tr>
</table>";
}
?>
<?php @require_once('../includes/copyright.php'); ?>
<?php mysql_close() ?>
</body>
</html>The $id tag seems to work everywhere else. What am I missing? Is there an "eregi (left-brain && hip-check)" function I need to study?
.