UPdate database problems

Here is the whole code…

[php]<?PHP
$reqlevel = 0;
include(“config.php”);
include(“members/membersonly.inc.php”);
$invID = $_POST[‘invIDH’];
$invID2 = $_POST[‘editItem1’];

if ($submit == “Delete Item”) {
$query = “DELETE from inventory where invID=’”.$invID."’";
$result = mysql_query($query);

}

elseif ($submit == “Edit Item”) {
$sql = (“SELECT * FROM inventory WHERE title = ‘{$_POST[‘selection’]}’”);
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
echo “

”;
echo " ";

echo “

Title
Price
Year
Make
Model
Miles
Interior Color
Exterior Color
Description $myrow[9]

”;
echo “


”;

}
elseif ($submit == “Modify Item”) {
$sql = (“SELECT * FROM inventory WHERE invid = ‘$_POST[invIDH]’”);
$result = mysql_query($sql);
if (!$result) {
error(‘A database error occured in processing your submission.\nIf this error perists, please contact webmaster@***.com.’);
}
$result = mysql_query(“UPDATE inventory SET title = ‘$_POST[title]’, miles = ‘$_POST[miles]’, price = ‘$_POST[price]’, year = ‘$_POST[year]’, make = ‘$_POST[make]’, model = ‘$_POST[model]’, incolor = ‘$_POST[incolor]’, excolor = ‘$_POST[excolor]’, description = ‘$_POST[description]’ WHERE invID = ‘$_POST[invIDH]’”) or die(mysql_error());

if (!$result) {
error(‘A database error occured in the processing your submission.\nIf this error persists, please contact webmaster@***.com.’);
}
}
?>

Exo Auto Sales
<?php $sql = "SELECT * FROM inventory"; $result = mysql_query($sql); if (!$result) { error('A database error occured in processing your submission.\nIf this error perists, please contact webmaster@***.com.'); } $num_rows = mysql_num_rows($result); for($i =0;$i<$num_rows;$i++) { $myrow = mysql_fetch_row($result); echo " "; print_r($myrow[1]); }
    	?>

  	</select>




<?PHP // get the current news items $query = "Select * from inventory ORDER BY 'postDate' DESC"; $result = mysql_query($query); while($row = mysql_fetch_array($result)){ ?>
<?PHP echo $row["title"]; ?>
')">" alt="Picture" align="left" border=0> <?php echo "Inventory id number: "; echo $row["invID"]; echo ""; ?>
Price: <?PHP echo $row["price"]; ?>
Year: <?PHP echo $row["year"]; ?>
Make: <?PHP echo $row["make"]; ?>
Model: <?PHP echo $row["model"]; ?>
Miles: <?PHP echo $row["miles"]; ?>
Interior color: <?PHP echo $row["incolor"]; ?>
Exterior color: <?PHP echo $row["excolor"]; ?>
Description: <?PHP echo $row["description"]; ?>
<?php } ?>
[/php]

THe problem im having is with this code right here…

[php]
elseif ($submit == “Modify Item”) {
$sql = (“SELECT * FROM inventory WHERE invid = ‘$_POST[invIDH]’”);
$result = mysql_query($sql);
if (!$result) {
error(‘A database error occured in processing your submission.\nIf this error perists, please contact webmaster@***.com.’);
}
$result = mysql_query(“UPDATE inventory SET title = ‘$_POST[title]’, miles = ‘$_POST[miles]’, price = ‘$_POST[price]’, year = ‘$_POST[year]’, make = ‘$_POST[make]’, model = ‘$_POST[model]’, incolor = ‘$_POST[incolor]’, excolor = ‘$_POST[excolor]’, description = ‘$_POST[description]’ WHERE invID = ‘$_POST[invIDH]’”) or die(mysql_error());

if (!$result) {
error(‘A database error occured in the processing your submission.\nIf this error persists, please contact webmaster@***.com.’);
}
}
[/php]

Every time i click the Modify item button it turns the seleceted database to all blank lines, just for the item im modifying all others stay the same… Im just trying to get it to update from the text fields that i have on the form, any help or suggestions would be lovely… =o thx

varify your $_POST variables have the form data. varify that the sql statement is exactly as you expect.

Ok i changed the modify item to just print $_POST[title]; and clicked modify and nothing printed out… Hmm trying to fig out why its not printing the form data…

LOLOL problem solved, thx for the help tho… i didnt have a on top of the form that is printed out just on the Buttons, so it wasnt geting the info lol… I knew it was something stupid and small… Anyway thx for the help tho =o

:)
Sponsor our Newsletter | Privacy Policy | Terms of Service