Jump to content

Recommended Posts

trying to let my clients update dates on their stories and events but it wont let me update...

heres the code

<?php
  ## Create month select
## set defaults
$year = date("Y");
$month = date("m");
$date = date("d");

## Use stored date field if we're editing
if ($do == "update") {
	$date_values = explode("-", $row[date]);
	$year = $date_values[0];
	$month = $date_values[1];
	$date = $date_values[2];
}

## Setup month select
for ($i = 1; $i <= 12; $i++) {
	$sel = "";
	$num = date("m", mktime(0, 0, 0, $i, 1, 2000));
	if ($month == $num) {
		$sel = " selected='selected'";
	}
	$month_opt .= "<option value='".$num."'".$sel.">".$i."</option>";
}

## Setup date select
for ($i = 1; $i <= 31; $i++) {
	$sel = "";
	$num = date("d", mktime(0, 0, 0, 1, $i, 2000));
	if ($date == $num) {
		$sel = " selected='selected'";
	}
	$date_opt .= "<option value='".$num."'".$sel.">".$i."</option>";
}

## Setup year select
for ($i = 2002; $i <= $year+1; $i++) {
	$sel = "";
	$num = date("Y", mktime(0, 0, 0, 1, 1, $i));
	if ($year == $num) {
		$sel = " selected='selected'";
	}
	$year_opt .= "<option value='".$num."'".$sel.">".$i."</option>";
}



$date = $_POST['year']."-". $_POST['month']."-".$_POST['date'];
$db_to_form = array(
	"region" => "region",
	"EMEA" => "1",
	"north_america" => "2",
	"latin_america" => "3",
	"asia_pacific" => "4",
	"greater_china" => "5",
	"doc_type" => "doc_type",
	"title" => "title",
	"abstract" => "abstract",
	"author" => "author",
	"page_content" => "page_content",
	"file" => "filename",
	"url" => "url",
	"source" => "source"
	//"date" => $date
);

if ($db_cols == "file") {

		$ins_db_cols .= "$db_cols,";
	$ins_db_values .= "'". $filename."',";
	$upd_db_values .= "$db_cols = '". $_POST['filename']."',";
	} else {
	if ($db_cols != "page_content") {
		$value = htmlspecialchars($value, ENT_QUOTES);
	}
	else $value = $value;
	$ins_db_cols .= "$db_cols, date,";
	$ins_db_values .= "'". $_POST[$value]."',";
	$upd_db_values .= "$db_cols = '". $_POST[$value]."',";
}
}

$ins_db_cols .= "date,";
$ins_db_values .= "'". $date ."',";

        $create_this_sql = "INSERT INTO ".$thisfile." (".$ins_db_cols.") VALUES (".$ins_db_values.")";
$update_this_sql = "UPDATE ".$thisfile." SET ".$upd_db_values." WHERE keyid = ".$_POST['key'];
$edit_this_sql = "SELECT * FROM ".$thisfile." WHERE keyid =". $id;
$delete_this_sql = "DELETE FROM ".$thisfile." WHERE keyid = ".$id;
?>

	<div style='clear: left;  margin-bottom:5px;'>
		<div style='float: left; text-align: right; width: 90px'>Document Date:</div>
		<div style='margin-left: 100px'><select ".$hidden." name='month'>".$month_opt."</select> / <select ".$hidden." name='date'>".$date_opt."</select> / <select ".$hidden." name='year'>".$year_opt."</select></div>
	</div>

<?php
  case "update":
  //echo $update_this_sql;
		mysql_query($update_this_sql);
		$key = $_POST['key'];
		if (isset($_POST['deletefile'])) {
		$deletefile = $_POST['deletefile'];
		//$key = $_POST['key'];
			mysql_query("UPDATE newsdocs SET file = '' WHERE keyid = ".$_POST['key']);
			## Connect to FTP
			$conn_id = ftp_connect($ftp_server);
			ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
			ftp_delete($conn_id, $key."_".$deletefile); //=====================CHECK THIS==========================================
			## Close the connection
			ftp_close($conn_id);
		}
?>

Link to comment
https://forums.phpfreaks.com/topic/75246-solved-date-update-is-not-working/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.