Member Avatar for chris055

I am a total newb

First I have this code:

$post_renew = trim(htmlspecialchars($_POST['renew']));

if ($post_renew && $_POST['ad'])
{

	$renew_days = ($admin_renew_days*86400);

	$expiry = time()+$renew_days;

	$expiry_dt = date("Y-m-d H:i:s", $expiry);
	
	
	if ($admin_renew_cre_dt == 1)
	{
		$create_date = date("Y-m-d H:i:s", time());
		$update_create_dt = ", createdon = '$create_date'";
	}


	$adlist = implode(" OR adid = ", $_POST['ad']);
	if ($adlist)
	{
		$adlist = "adid = " . $adlist;
		$sql = "UPDATE $table SET expireson = '$expiry_dt' $update_create_dt WHERE $adlist";
		//echo $sql; // testing
		if(mysql_query($sql)) $msg = mysql_affected_rows() . " ad(s) have been renewed";
		else $err = "Error renewing ads";
	}
}

But i have a variable called $fullcode

If a user enters a $fullcode that is already in the database, I want the "createdon" variable to be updated with the submit button

this may help

<?

// update.php

require("./resources/globals.php") ;


$updateStmt = "Update Garant SET 
akey=$akey,
Ref='$Ref',
Broker='$Broker',
Brokerphone='$Brokerphone',
Brokeremail='$Brokeremail',
Comments='$Comments',
BGComments='$BGComments',
Price='$Price',
Location='$Location',
Town='$Town',
smallpic='$smallpic', 
Pic1='$Pic1',
Pic2='$Pic2',
Pic3='$Pic3',
Pic4='$Pic4',
Portfolio='$Portfolio', 
Size='$Size',
Condition='$Condition', 
Plotsize='$Plotsize', 
Roadaccess='$Roadaccess',
Distance='$Distance',
type='$type',
Electricity='$Electricity', 
Water='$Water', 
garage='$garage', 
bedrooms='$bedrooms', 
Kitchen='$Kitchen', 
Status='$Status', 
WC='$WC' WHERE akey = '$akey' ";

// Connect to the Database
if (!($link=mysql_pconnect($location,$userName,$password))) {
   DisplayErrMsg(sprintf("error connecting to host %s, by user %s",
                             $location, $userName)) ;
   exit() ;
}

// Select the Database
if (!mysql_select_db($dbname, $link)) {
   DisplayErrMsg(sprintf("Error in selecting %s database", $dbname)) ;
   DisplayErrMsg(sprintf("error:%d %s", mysql_errno($link), mysql_error($link))) ;
   exit() ;
}
echo $updateStmt;
// Execute the Statement
if (!mysql_query ($updateStmt)){

// Execute the Statement
//if (!mysql_query($updateStmt, $link)) {
   DisplayErrMsg(sprintf("Error in executing %s stmt", $updateStmt)) ;
   DisplayErrMsg(sprintf("error:%d %s", mysql_errno($link), mysql_error($link))) ;
   exit() ;
}

GenerateHTMLHeader("The entry was modified succesfully");

ReturnToDisplay( );

?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.