Solved

get time and update row

Posted on 2012-03-10
2
258 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 77

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

860 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