Re: trouble with my edit form code
Posted: Thu Oct 01, 2009 8:30 pm
cool. no worries. Here's what displayed: NULL bool(true)
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
<input type="text" [color=#FF0000]name="vitd"[/color] maxlength="30" value="<?php echo isset([color=#0000FF]$vitd[/color]) ? [color=#0000FF]$vitd[/color] : ''; ?>" />and update my:<input type="text" name="vitd2" maxlength="30" value="<?php echo isset($vitd) ? $vitd : ''; ?>" />
Code: Select all
$iron = $_POST['iron'];
$vitd2 = $_POST['vitd2'];
$vite = $_POST['vite'];Code: Select all
<?
if(isset($_GET['fid'])){
$fid=$_GET['fid'];
//connect to the database
$sql="SELECT * FROM FoodLib WHERE foodid=" . $fid;
//-run the query against the mysql query function
$result=mysql_query($sql);
//-create while loop and loop through result set
while($row=mysql_fetch_array($result)){
$foodname =$row['foodname'];
$foodsubname =$row['foodsubname'];
$vitd = $row['[color=#FF0000]vitd[/color]'];
........etc etc etcCode: Select all
function updateFood()
{
/* Add the new account to the database */
$foodname = mysql_real_escape_string($_POST['foodname']);
$foodsubname = mysql_real_escape_string($_POST['foodsubname']);
$vitd = $_POST['[color=#FF0000]vitd[/color]'];
Code: Select all
[color=#FF0000]code came b4......[/color]$manganese = $_POST['manganese'];
$chromium = $_POST['chromium'];
$molybdenum = $_POST['molybdenum'];
$q = "UPDATE FoodLib SET foodname = '$foodname', foodsubname = '$foodsubname', brand = '$brand', description = '$description', foodtype = '$foodtype', upccode = '$upccode', servingsize = '$servingsize', servingunits = '$servingunits', servingsize2 = '$servingsize2', servingunits2 = '$servingunits2', servingsize3 = '$servingsize3', servingunits3 = '$servingunits3', calories = '$calories', calfromfat = '$calfromfat', totalfat = '$totalfat', satfat = '$satfat', transfat = '$transfat', polyunsatfat = '$polyunsatfat', monounsatfat = '$monounsatfat', cholesterol = '$cholesterol', sodium = '$sodium'
, potassium = '$potassium' , totalcarb = '$totalcarb', dietaryfiber = '$dietaryfiber', sugar = '$sugar', protein = '$protein', vita = '$vita', vitc = '$vitc', calcium = '$calcium', iron = '$iron', vitd = '$vitd', vite = '$vite', vitk = '$vitk', thiamin = '$thiamin', riboflavin = '$riboflavin', niacin = '$niacin', vitb6 = '$vitb6', folicacid = '$folicacid', vitb12 = '$vitb12', biotin = '$biotin', pantothenicacid = '$pantothenicacid', phosphorus = '$phosphorus', iodine = '$iodine', magnesium = '$magnesium', zinc = '$zinc', selenium = '$selenium', copper = '$copper', manganese = '$manganese', chromium = '$chromium', molybdenum = '$molybdenum' WHERE foodid = [color=#FF0000]'$fid'[/color]";
$ureturn = mysql_query($q) or die(mysql_error());
} Code: Select all
$manganese = $_POST['manganese'];
$chromium = $_POST['chromium'];
$molybdenum = $_POST['molybdenum'];
[color=#FF0000] $fid=$_GET['fid'];[/color]
$q = "UPDATE FoodLib SET foodname = '$foodname', foodsubname = '$foodsubname', brand = '$brand', description = '$description', foodtype = '$foodtype', upccode = '$upccode', servingsize = '$servingsize', servingunits = '$servingunits', servingsize2 = '$servingsize2', servingunits2 = '$servingunits2', servingsize3 = '$servingsize3', servingunits3 = '$servingunits3', calories = '$calories', calfromfat = '$calfromfat', totalfat = '$totalfat', satfat = '$satfat', transfat = '$transfat', polyunsatfat = '$polyunsatfat', monounsatfat = '$monounsatfat', cholesterol = '$cholesterol', sodium = '$sodium'
, potassium = '$potassium' , totalcarb = '$totalcarb', dietaryfiber = '$dietaryfiber', sugar = '$sugar', protein = '$protein', vita = '$vita', vitc = '$vitc', calcium = '$calcium', iron = '$iron', vitd = '$vitd', vite = '$vite', vitk = '$vitk', thiamin = '$thiamin', riboflavin = '$riboflavin', niacin = '$niacin', vitb6 = '$vitb6', folicacid = '$folicacid', vitb12 = '$vitb12', biotin = '$biotin', pantothenicacid = '$pantothenicacid', phosphorus = '$phosphorus', iodine = '$iodine', magnesium = '$magnesium', zinc = '$zinc', selenium = '$selenium', copper = '$copper', manganese = '$manganese', chromium = '$chromium', molybdenum = '$molybdenum' WHERE foodid = [color=#FF0000]'$fid'[/color]";
$ureturn = mysql_query($q) or die(mysql_error());
}
Code: Select all
<?
if(isset($_GET['fid'])){
$fid=$_GET['fid'];
//connect to the database
$sql="SELECT * FROM FoodLib WHERE foodid=" . $fid;
//-run the query against the mysql query function
$result=mysql_query($sql);
//-create while loop and loop through result set
while($row=mysql_fetch_array($result)){
$foodname =$row['foodname'];
$foodsubname =$row['foodsubname'];
$brand = $row['brand'];
$description = $row['description'];
$foodtype = $row['foodtype'];
$upccode = $row['upccode'];
$servingsize = $row['servingsize'];
$servingunits = $row['servingunits'];
$servingsize2 = $row['servingsize2'];
$servingunits2 = $row['servingunits2'];
$servingsize3 = $row['servingsize3'];
$servingunits3 = $row['servingunits3'];
$calories = $row['calories'];
$calfromfat = $row['calfromfat'];
$totalfat = $row['totalfat'];
$satfat = $row['satfat'];
$transfat = $row['transfat'];
$polyunsatfat = $row['polyunsatfat'];
$monounsatfat = $row['monounsatfat'];
$cholesterol = $row['cholesterol'];
$sodium = $row['sodium'];
$potassium = $row['potassium'];
$totalcarb = $row['totalcarb'];
$dietaryfiber = $row['dietaryfiber'];
$sugar = $row['sugar'];
$protein = $row['protein'];
$vita = $row['vita'];
$vitc = $row['vitc'];
$calcium = $row['calcium'];
$iron = $row['iron'];
$vitd = $row['vitd'];
$vite = $row['vite'];
$vitk = $row['vitk'];
$thiamin = $row['thiamin'];
$riboflavin = $row['riboflavin'];
$niacin = $row['niacin'];
$vitb6 = $row['vitb6'];
$folicacid = $row['folicacid'];
$vitb12 = $row['vitb12'];
$biotin = $row['biotin'];
$pantothenicacid = $row['pantothenicacid'];
$phosphorus = $row['phosphorus'];
$iodine = $row['iodine'];
$magnesium = $row['magnesium'];
$zinc = $row['zinc'];
$selenium = $row['selenium'];
$copper = $row['copper'];
$manganese = $row['manganese'];
$chromium = $row['chromium'];
$molybdenum = $row['molybdenum'];
$optionname = $row['optionname'];
}
}
?>
<?
include("includes/profilecredentials.php");
?>
<?php
if (get_magic_quotes_gpc()) {
$in = array(&$_GET, &$_POST, &$_COOKIE);
while (list($k,$v) = each($in)) {
foreach ($v as $key => $val) {
if (!is_array($val)) {
$in[$k][$key] = stripslashes($val);
continue;
}
$in[] =& $in[$k][$key];
}
}
unset($in);
}
?>
<?
if(isset($_POST['subjoin'])){
/* A whole lot of validation code was here --- Removed it so I can post it. There's a character count limit :) */
function updateFood()
{
/* Add the new account to the database */
$foodname = mysql_real_escape_string($_POST['foodname']);
$foodsubname = mysql_real_escape_string($_POST['foodsubname']);
$brand = mysql_real_escape_string($_POST['brand']);
$description = mysql_real_escape_string($_POST['description']);
$foodtype = $_POST['foodtype'];
$upccode = $_POST['upccode'];
$servingsize = trim($_POST['servingsize']);
$servingunits = trim($_POST['servingunits']);
$servingsize2 = $_POST['servingsize2'];
$servingunits2 = $_POST['servingunits2'];
$servingsize3 = $_POST['servingsize3'];
$servingunits3 = $_POST['servingunits3'];
$calories = trim($_POST['calories']);
$calfromfat = $_POST['calfromfat'];
$totalfat = $_POST['totalfat'];
$satfat = $_POST['satfat'];
$transfat = $_POST['transfat'];
$polyunsatfat = $_POST['polyunsatfat'];
$monounsatfat = $_POST['monounsatfat'];
$cholesterol = $_POST['cholesterol'];
$sodium = $_POST['sodium'];
$potassium = $_POST['potassium'];
$totalcarb = $_POST['totalcarb'];
$dietaryfiber = $_POST['dietaryfiber'];
$sugar = $_POST['sugar'];
$protein = $_POST['protein'];
$vita = $_POST['vita'];
$vitc = $_POST['vitc'];
$calcium = $_POST['calcium'];
$iron = $_POST['iron'];
$vitd = $_POST['vitd'];
$vite = $_POST['vite'];
$vitk = $_POST['vitk'];
$thiamin = $_POST['thiamin'];
$riboflavin = $_POST['riboflavin'];
$niacin = $_POST['niacin'];
$vitb6 = $_POST['vitb6'];
$folicacid = $_POST['folicacid'];
$vitb12 = $_POST['vitb12'];
$biotin = $_POST['biotin'];
$pantothenicacid = $_POST['pantothenicacid'];
$phosphorus = $_POST['phosphorus'];
$iodine = $_POST['iodine'];
$magnesium = $_POST['magnesium'];
$zinc = $_POST['zinc'];
$selenium = $_POST['selenium'];
$copper = $_POST['copper'];
$manganese = $_POST['manganese'];
$chromium = $_POST['chromium'];
$molybdenum = $_POST['molybdenum'];
$fid=$_GET['fid'];
$q = "UPDATE FoodLib SET foodname = '$foodname', foodsubname = '$foodsubname', brand = '$brand', description = '$description', foodtype = '$foodtype', upccode = '$upccode', servingsize = '$servingsize', servingunits = '$servingunits', servingsize2 = '$servingsize2', servingunits2 = '$servingunits2', servingsize3 = '$servingsize3', servingunits3 = '$servingunits3', calories = '$calories', calfromfat = '$calfromfat', totalfat = '$totalfat', satfat = '$satfat', transfat = '$transfat', polyunsatfat = '$polyunsatfat', monounsatfat = '$monounsatfat', cholesterol = '$cholesterol', sodium = '$sodium'
, potassium = '$potassium' , totalcarb = '$totalcarb', dietaryfiber = '$dietaryfiber', sugar = '$sugar', protein = '$protein', vita = '$vita', vitc = '$vitc', calcium = '$calcium', iron = '$iron', vitd = '$vitd', vite = '$vite', vitk = '$vitk', thiamin = '$thiamin', riboflavin = '$riboflavin', niacin = '$niacin', vitb6 = '$vitb6', folicacid = '$folicacid', vitb12 = '$vitb12', biotin = '$biotin', pantothenicacid = '$pantothenicacid', phosphorus = '$phosphorus', iodine = '$iodine', magnesium = '$magnesium', zinc = '$zinc', selenium = '$selenium', copper = '$copper', manganese = '$manganese', chromium = '$chromium', molybdenum = '$molybdenum' WHERE foodid = '$fid'";
$ureturn = mysql_query($q) or die(mysql_error());
header( 'Location: http://www.url.com/membersarea/fooddeta ... fid='.$fid);
}
if(empty($reqerrors) && empty($errors) && empty($reqverrors)){
updateFood();
}
else {
$anyerror = "\t<div class=pred>FOOD UPDATE NOT YET SUBMITTED!</div>\n";
}
if(empty($reqerrors)) {
}
else {
$reqberror = "\t<div class=pred><b>ERROR: </b>You didn't fill in a required field. See below.</div>\n";
}
if(empty($reqverrors)) {
}
else {
$reqverror = "\t<div class=pred><b>ERROR: </b>You entered an invalid value in a required field. See below.</div>\n";
}
if(empty($errors)) {
}
else {
$optverror = "\t<div class=pred><b>ERROR: </b>You entered an invalid value in an optional field. See below.</div>\n";
}
}
?>