Solved

get time and update row

Posted on 2012-03-10
2
260 Views
Last Modified: 2012-03-10
I'm trying to do 2 things... My code works but I need it to record the time the data is saved so I can see if the data is stale also is there such thing as a insert or replace function or Update because I don't want to generate a new row every time but simply check if a user and group existent and update that row or if it doesn't then create the row... I know I use insert or replace in sqlite how about php --> mysql ?


<?php
$dbhost =xxxx
$dbuser = xxxx
$dbpass = xxxxx;
$dbname=xxxxx;


$con = mysql_connect("$dbhost","$dbuser","$dbpass");
mysql_select_db($dbname);

if (!$con)

  {
  die('Could not connect: ' . mysql_error());
  }


$sql="INSERT INTO gpscoordinates (UserName, Password1, Group1,Latitude,Longitude)
VALUES
('$_POST[User]','$_POST[Password1]','$_POST[Group1]','$_POST[Latitude]','$_POST[Longitude]')";

//$sql="INSERT INTO gpscoordinates (UserName, Password1, Group1,Latitude,Longitude)
//VALUES ('1','2','3','4','5')";


if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";

mysql_close($con)
?> 

Open in new window

0
Comment
Question by:dolamitejenkins
2 Comments
 
LVL 78

Accepted Solution

by:
arnold earned 500 total points
ID: 37706125
If you have a datetime, or an int(11) for time keeping (actual date or unix timestamp)
you can use now() or unix_timestamp() for the columns when you do the insert, replace/update.
0
 

Author Closing Comment

by:dolamitejenkins
ID: 37706198
thanks
0

Featured Post

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to create an extensible mechanism for linked drop downs.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how the fundamental information of how to create a table.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question