Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
| Search | Today's Posts | Mark Forums Read
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 22nd, 2006, 04:57 PM
Registered User
 
Join Date: Oct 2006
Location: phoenix, as, .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default using multiple timestamps

Greetings,
I am using one database and I want to have 3 forms acessing it. My original form, submits to the db and is assigned a timestamp. (this works fine)The second form will update the database as will a 3rd form.
My update form(s) is causing me grief by either overwriting the original timestamp, or using a default of 0000-00-00 00:00:00. (not acceptable, I have tried both timestamp and datetime)
I am sorry, I am having problems and am not sure if this is a problem with my form, or the database. I will post the code for the first update form below, Thank you in advance,


<?php
if (!(isset($_POST['SubmitForm_x']))) {
$whereStmt = ' IDNum="'.addslashes($_GET['IDNum']).'"';
$selectSql = 'SELECT * FROM cactus2 WHERE '.$whereStmt ;
$Result = $MyDb->f_ExecuteSql($selectSql);
$Resultset = $MyDb->f_GetRecord($Result);
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Update</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="scripts/pdw.js"></script>
<script type="text/javascript">
function checkForm(){
formErrors = new Array();

isValidAny(document.getElementById('TLIN_ID'), 'TLIN:: null', true);


var errorText = '';
if (formErrors.length > 0){
for (var i=0; i<formErrors.length; i++)
errorText = errorText + formErrors[i] + '\n';
alert(errorText);
return false;
}

return true;
}
</script>

</head>
<body>
<form name="UpdateForm" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" onSubmit="return checkForm()">
<div id="insertblock">
<table>
<tr>
<td class="tableheader" colspan="2">Update</td>
</tr>
<tr>
<th>Assigned to:</th>
<td><input type="text" name="TLIN" id="TLIN_ID" value="<?php echo $Resultset['TLIN']; ?>"></td>
</tr>
<tr>
<?php
echo '<td class="tablefooter" colspan="2"><a href="javascript:history.back()"><img src="style/back.gif" alt="Back"></a>';
echo '<input type="image" src="style/update.gif" name="SubmitForm">';
?>
<input type="hidden" name="hidden_whereStmt" value='<?php echo $whereStmt; ?>'></td>
</tr>
</table>
</div>
</form>
</body>
</html>
<?php
}
else {
$updateSql = 'UPDATE cactus2 SET '
." TLIN='".addslashes($_POST['TLIN'])."'"
.' WHERE '.stripslashes($_POST['hidden_whereStmt']);
// cast it to an integer to make it safe
$id = (int) $_POST['id'];
$sql = "
...
WHERE id=$id
";

$MyDb->f_ExecuteSql($updateSql);

header('Location: list.php');
}
?>



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Display Timestamps from MS SQL 2000? thetwai C# 1 March 13th, 2007 07:43 AM
Multiple ADO multiple user login Oracle9i jhay0721 Pro VB Databases 1 April 4th, 2005 11:23 AM
Record timestamps JeffMM Classic ASP Databases 0 March 24th, 2004 03:14 AM
DATE\\Timestamps bph Access VBA 2 January 29th, 2004 03:02 PM
Help with GMT timestamps javahelpet JSP Basics 0 December 31st, 2003 02:54 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.