473,397 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Help with attempting to add time to a MySQL field from PHP?

In my feeble attempt to keep track of login session timeouts I have the
following code in my login section of my program:

$sql = "UPDATE subscriber
SET _sessexp = 'DATE_ADD(NOW(),INTERVAL 15 MINUTES)'
WHERE _userid = '$_userid'
LIMIT 1";

and when run I see NO ERRORS. However, either the field in the DB doesn't
change OR this expression is generating a value of '0' for the _sessexp
field.

I've tried using the ADDTIME function as an alternative but get the same
results. I'm kind of at a loss.

Any ideas as to why this is NOT behaving as I expect it to?

What I am attempting to do is to take the CURRENT TIME and add 15 minutes to
it and update a field in the database record. That simple!

Bob
Jul 18 '06 #1
3 2645
Rik
bobmct wrote:
In my feeble attempt to keep track of login session timeouts I have
the following code in my login section of my program:

$sql = "UPDATE subscriber
SET _sessexp = 'DATE_ADD(NOW(),INTERVAL 15 MINUTES)'
WHERE _userid = '$_userid'
LIMIT 1";

and when run I see NO ERRORS. However, either the field in the DB
doesn't change OR this expression is generating a value of '0' for
the _sessexp field.

I've tried using the ADDTIME function as an alternative but get the
same results. I'm kind of at a loss.

Any ideas as to why this is NOT behaving as I expect it to?

What I am attempting to do is to take the CURRENT TIME and add 15
minutes to it and update a field in the database record. That simple!
First of all, you try to add the string 'DATE_ADD(NOW(),INTERVAL 15
MINUTES)' to a date field, which is invalid and will result to 0. Remove the
quotes.
Grtz,
--
Rik Wasmus
Jul 18 '06 #2
Rik wrote:
bobmct wrote:
>In my feeble attempt to keep track of login session timeouts I have
the following code in my login section of my program:

$sql = "UPDATE subscriber
SET _sessexp = 'DATE_ADD(NOW(),INTERVAL 15 MINUTES)'
WHERE _userid = '$_userid'
LIMIT 1";

and when run I see NO ERRORS. However, either the field in the DB
doesn't change OR this expression is generating a value of '0' for
the _sessexp field.

I've tried using the ADDTIME function as an alternative but get the
same results. I'm kind of at a loss.

Any ideas as to why this is NOT behaving as I expect it to?

What I am attempting to do is to take the CURRENT TIME and add 15
minutes to it and update a field in the database record. That simple!

First of all, you try to add the string 'DATE_ADD(NOW(),INTERVAL 15
MINUTES)' to a date field, which is invalid and will result to 0. Remove
the quotes.
Grtz,

Well, OK;

Already tried that first. With/without, single/double, doesn't seem to
matter.

Re-tried your suggestion and the result STILL results in ONLY ZERO in the
field. However, can a time function's result be put into a bigint field?

Bob
Jul 18 '06 #3
Rik
bobmct wrote:
Rik wrote:
>bobmct wrote:
>>In my feeble attempt to keep track of login session timeouts I have
the following code in my login section of my program:

$sql = "UPDATE subscriber
SET _sessexp = 'DATE_ADD(NOW(),INTERVAL 15 MINUTES)'
WHERE _userid = '$_userid'
LIMIT 1";

and when run I see NO ERRORS. However, either the field in the DB
doesn't change OR this expression is generating a value of '0' for
the _sessexp field.

I've tried using the ADDTIME function as an alternative but get the
same results. I'm kind of at a loss.

Any ideas as to why this is NOT behaving as I expect it to?

What I am attempting to do is to take the CURRENT TIME and add 15
minutes to it and update a field in the database record. That
simple!

First of all, you try to add the string 'DATE_ADD(NOW(),INTERVAL 15
MINUTES)' to a date field, which is invalid and will result to 0.
Remove the quotes.
Grtz,


Well, OK;

Already tried that first. With/without, single/double, doesn't seem
to matter.
Re-tried your suggestion and the result STILL results in ONLY ZERO in
the field.
DATE_ADD(NOW(), INTERVAL 15 MINUTE)

NO 's' after MINUTE
However, can a time function's result be put into a
bigint field?
I'm not sure what database you use, but in recent MySQL versions it will
return a format of yyyy-mm-dd hh:mm:ss, not an integer.

Do you by any chance mean UNIX_TIMESTAMP(DATE_ADD(NOW(), INTERVAL 15
MINUTE))?

Grtz,
--
Rik Wasmus
Jul 18 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Shanfeng Cheng | last post by:
I write a piece of code to tracking the number of clicks on a link each day. The link usu. gets about 3000-6000 clicks per day. I just store today's click count in a one-line text file, like, ...
7
by: redneck_kiwi | last post by:
Need some opinions on how best to display in excess of 14K records based on users search criteria. Application Concept: ----------------------- User enters various search criteria (as many...
0
by: Mark Adams | last post by:
I really need some help with this. MySQL will not start on boot despite everything I've done to make sure that it is set to do so. When I start it as root from a terminal with...
1
by: Mark Hargreaves | last post by:
Hopefully someone can help me here. I have a personnel database with numerous tables, although only a few are required for this particular query. I will name them as follows: master - holds...
1
by: George Develekos | last post by:
I need to import into mysql data from DB2. One of the DB2 table columns is of the TIMESTAMP type, which, unlike its MySQL counterpart, supports fractions of a second, up to 6 digits, i.e. it is of...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
2
by: phillip.s.powell | last post by:
I have to migrate data from one database table to another table in another database where the fields do not match, not even in the same order, and even if they do match, on occasions the datatypes...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
8
by: sathyashrayan | last post by:
Dear group, For a log-in page I have created a mysql db and user registers with a user name and password. The password field is encrypted with $passwd = sha1($_REQUEST); I insert the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.