Hi All,
When i'm grabbing a row from my database and then trying to UPDATE those details it's not updating and I don't see why:
DB Structure
story_id (int 1)
published_web_date_time (timestamp 0000-00-00 00:00:00)
So when I GET the data I get the published_web_date_time split into two textfields as shown in the form below, but when it comes to updating these textfields with new values it does not save the data to the database?
Any ideas?
Thanks
PHP Code:<?php
// ** Get the requested story id from the database **
if(isset($_GET['story_id']))
{
$result = mysql_query("Select * From cms_test where story_id=".$_GET['story_id']);
$row = mysql_fetch_array($result);
$date_time_array = explode(" ",$row['published_web_date_time']);
$published_web_date = $date_time_array[0];
$published_web_time = $date_time_array[1];
}
// ** If Submit is hit do your stuff **
if (isset($_POST['Submit'])) {
$published_web_date_time = $_POST['published_web_date_time'];
// ** Check for Required Fields with IF statements **
if (empty($published_web_date)){
$error = "** no time! **";
} else if (empty($published_web_time)){
$error = "** no date! **";
// ** If all of the statements are true then **
} else {
$query = mysql_query("Update cms_test set published_web_date_time='$published_web_date $published_web_time' where story_id=".$_GET['story_id']);
header('Location: done.php');
// ** And finally run the query to add data to the database **
$link = mysql_connect;
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
mysql_close();
}
}
?>
<FORM ACTION="".php" method="post" NAME="frmAdd">
Date: <INPUT NAME="published_web_date" TYPE="text" ID="published_web_date" VALUE="<?php echo $published_web_date?>" SIZE="18">
<br />
<br / >
Time: <INPUT NAME="published_web_time" TYPE="text" ID="published_web_time" VALUE="<?php echo $published_web_time?>" SIZE="18"><br />
<br />
<INPUT TYPE="Submit" NAME="Submit" VALUE="Submit" CLASS="button">
</form>


Reply With Quote
Bookmarks