PDA

View Full Version : Help with an edit form


2bz2p
08-01-2008, 04:41 AM
Hi,

So I have troubleshooted this to the tip of my knowledge. The form is posting and the code is catching it but once its the Database codes turn it doesnt post it to the db.

heres the code:
(at the bottom you will see where I was testing the post variables and they did echo the correct values)
//////////////////////////////////////////////
// this is the PHP for Editing an aircraft////
//////////////////////////////////////////////

function edit_php() {

global $database_conn_abrv, $conn_abrv;

mysql_select_db($database_conn_abrv, $conn_abrv);
$query_fleet = "SELECT * FROM fleet";
$fleet = mysql_query($query_fleet, $conn_abrv) or die(mysql_error());
$row_fleet = mysql_fetch_assoc ($fleet);
$total_rows_fleet = mysql_num_rows($fleet);

if(isset($_POST['update'])) {
if ($_FILES['uploadedfile']['name'] !== ""){
$target_path = $cfg['dir'] . 'source/images/fleet/' . $_FILES['uploadedfile']['name'];
move_uploaded_file($_FILES['uploadedfile']['tmp_name'],$target_path);
$eimage = $_FILES['uploadedfile']['name'];
}
else {
$eimage = $row_fleet['image'];
}

$ename = addslashes(trim($_POST['name']));
$eserv_date = addslashes(trim($_POST['serv_date']));
$edescription = addslashes(trim($_POST['description']));

/*lets update the DB*/
mysql_select_db($database_conn_abrv, $conn_abrv);
$query_in = "UPDATE fleet SET name = '$ename', description = '$edescription', image = '$eimage', serv_date = '$eserv_date' WHERE id = '$id'";
$in = mysql_query($query_in, $conn_abrv) or die(mysql_error("is it creating an error"));

/*header( 'Location:'.$cfg['domain'].'?action=fleet&change=edited');
exit;*/

echo $ename."<br>";
echo $eserv_date."<br>";
echo $edescription."<BR>";
echo $eimage."<BR>";
echo $row_fleet['name']."<br>";

}
return;
}

Thanks
2b

edbr
08-01-2008, 04:59 AM
echo $id,

2bz2p
08-01-2008, 05:26 AM
Thank god for these forums man, 1 simple forgotten varible and it blows the whole code into the wind.

Wish I saw it an hour and a half ago lol
Thanks
2b

davidj
08-01-2008, 07:00 AM
hehehehe

you will debug code for hours sometimes only to find that you have missed a $ or have a rogue ;

2bz2p
08-01-2008, 07:37 PM
yeah just figured that one out lol. :roll:

:-)
2b