Timestamps
am 30.04.2008 17:29:24 von Jason Pruim
Okay... So I know this should be simple...
Trying to store a timestamp in a MySQL database... The timestamp I am
making like so: $modifiedTimestamp = time();
and then just $sql = "Update `mytable` set
timestamp='$modifiedTimestamp' where Record='1'";
Simple right? Not quite...in my database it's storing a "0" in the
timestamp field which is a int(10) field.
I have googled, and searched manuals, but have not been able to figure
out what is going on....
Any Ideas?
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
japruim@raoset.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Timestamps
am 30.04.2008 17:35:17 von Stut
On 30 Apr 2008, at 16:29, Jason Pruim wrote:
> Okay... So I know this should be simple...
>
> Trying to store a timestamp in a MySQL database... The timestamp I
> am making like so: $modifiedTimestamp = time();
>
> and then just $sql = "Update `mytable` set
> timestamp='$modifiedTimestamp' where Record='1'";
>
> Simple right? Not quite...in my database it's storing a "0" in the
> timestamp field which is a int(10) field.
>
> I have googled, and searched manuals, but have not been able to
> figure out what is going on....
>
> Any Ideas?
timestamp is a reserved word. Try putting it in backticks.
-Stut
--
http://stut.net/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Timestamps
am 30.04.2008 17:38:02 von Jason Pruim
On Apr 30, 2008, at 11:35 AM, Stut wrote:
> On 30 Apr 2008, at 16:29, Jason Pruim wrote:
>> Okay... So I know this should be simple...
>>
>> Trying to store a timestamp in a MySQL database... The timestamp I
>> am making like so: $modifiedTimestamp = time();
>>
>> and then just $sql = "Update `mytable` set
>> timestamp='$modifiedTimestamp' where Record='1'";
>>
>> Simple right? Not quite...in my database it's storing a "0" in the
>> timestamp field which is a int(10) field.
>>
>> I have googled, and searched manuals, but have not been able to
>> figure out what is going on....
>>
>> Any Ideas?
>
> timestamp is a reserved word. Try putting it in backticks.
Okay, so I did a really crappy job at my sudo code... The field name
is actually Last_Updated.
so my update code looks like this: Last_Updated='$modifiedTimestamp'
*Slaps his wrist... Bad copy/paste! BAD!!!
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
japruim@raoset.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Timestamps
am 30.04.2008 17:47:35 von Yves Sucaet
Hi Jason,
It's not because you create a date/time value that you automatically have=
an
integer-value. You need to specify first that you want the date/time valu=
e
converted to an integer value first. =
See
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functio ns.html#funct=
ion_unix-timestamp
for an example of how to do this. =
Actually, by using this function, you probably don't even need to create =
the
$modifiedTimestamp variable anymore. You can just write your SQL query as=
follows:
$sql =3D "Update `mytable` set timestamp=3DUNIX_TIMESTAMP() where Record=3D=
'1'";
HTH,
Yves
------ Original Message ------
Received: Wed, 30 Apr 2008 10:39:11 AM CDT
From: Jason Pruim
To: Stut Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] Timestamps
On Apr 30, 2008, at 11:35 AM, Stut wrote:
> On 30 Apr 2008, at 16:29, Jason Pruim wrote:
>> Okay... So I know this should be simple...
>>
>> Trying to store a timestamp in a MySQL database... The timestamp I =
>> am making like so: $modifiedTimestamp =3D time();
>>
>> and then just $sql =3D "Update `mytable` set =
>> timestamp=3D'$modifiedTimestamp' where Record=3D'1'";
>>
>> Simple right? Not quite...in my database it's storing a "0" in the =
>> timestamp field which is a int(10) field.
>>
>> I have googled, and searched manuals, but have not been able to =
>> figure out what is going on....
>>
>> Any Ideas?
>
> timestamp is a reserved word. Try putting it in backticks.
Okay, so I did a really crappy job at my sudo code... The field name =
is actually Last_Updated.
so my update code looks like this: Last_Updated=3D'$modifiedTimestamp'
*Slaps his wrist... Bad copy/paste! BAD!!!
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
japruim@raoset.com
-- =
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Timestamps
am 30.04.2008 17:54:04 von Jason Pruim
Hi Yves,
Thanks for the tip, that worked, I think I'll use that from now on..
Just out of curiosity though, any idea why it wasn't working as I was
writing it :)
On Apr 30, 2008, at 11:47 AM, YVES SUCAET wrote:
> Hi Jason,
>
> It's not because you create a date/time value that you automatically
> have an
> integer-value. You need to specify first that you want the date/time
> value
> converted to an integer value first.
>
> See
> http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functio ns.html#function_unix-timestamp
> for an example of how to do this.
>
> Actually, by using this function, you probably don't even need to
> create the
> $modifiedTimestamp variable anymore. You can just write your SQL
> query as
> follows:
>
> $sql = "Update `mytable` set timestamp=UNIX_TIMESTAMP() where
> Record='1'";
>
> HTH,
>
> Yves
>
> ------ Original Message ------
> Received: Wed, 30 Apr 2008 10:39:11 AM CDT
> From: Jason Pruim
> To: Stut Cc: php-db@lists.php.net
> Subject: Re: [PHP-DB] Timestamps
>
>
> On Apr 30, 2008, at 11:35 AM, Stut wrote:
>
>> On 30 Apr 2008, at 16:29, Jason Pruim wrote:
>>> Okay... So I know this should be simple...
>>>
>>> Trying to store a timestamp in a MySQL database... The timestamp I
>>> am making like so: $modifiedTimestamp = time();
>>>
>>> and then just $sql = "Update `mytable` set
>>> timestamp='$modifiedTimestamp' where Record='1'";
>>>
>>> Simple right? Not quite...in my database it's storing a "0" in the
>>> timestamp field which is a int(10) field.
>>>
>>> I have googled, and searched manuals, but have not been able to
>>> figure out what is going on....
>>>
>>> Any Ideas?
>>
>> timestamp is a reserved word. Try putting it in backticks.
>
>
> Okay, so I did a really crappy job at my sudo code... The field name
> is actually Last_Updated.
>
> so my update code looks like this: Last_Updated='$modifiedTimestamp'
>
> *Slaps his wrist... Bad copy/paste! BAD!!!
>
> --
>
> Jason Pruim
> Raoset Inc.
> Technology Manager
> MQC Specialist
> 3251 132nd ave
> Holland, MI, 49424-9337
> www.raoset.com
> japruim@raoset.com
>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
japruim@raoset.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Timestamps
am 30.04.2008 23:03:06 von Philip Thompson
On Apr 30, 2008, at 10:54 AM, Jason Pruim wrote:
> Hi Yves,
>
> Thanks for the tip, that worked, I think I'll use that from now on..
>
> Just out of curiosity though, any idea why it wasn't working as I
> was writing it :)
Did you try putting the query that PHP is generating in phpMyAdmin or
MySQL Query Browser? See if it throws an error when attempting to
update. It *appears* that the query should work.
~Philip
PS... Was it you, Jason, or someone else who asked about the security
of the community knowing their database structure and I encouraged the
use of `backticks` around all field and table names?
> On Apr 30, 2008, at 11:47 AM, YVES SUCAET wrote:
>
>> Hi Jason,
>>
>> It's not because you create a date/time value that you
>> automatically have an
>> integer-value. You need to specify first that you want the date/
>> time value
>> converted to an integer value first.
>>
>> See
>> http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functio ns.html#function_unix-timestamp
>> for an example of how to do this.
>>
>> Actually, by using this function, you probably don't even need to
>> create the
>> $modifiedTimestamp variable anymore. You can just write your SQL
>> query as
>> follows:
>>
>> $sql = "Update `mytable` set timestamp=UNIX_TIMESTAMP() where
>> Record='1'";
>>
>> HTH,
>>
>> Yves
>>
>> ------ Original Message ------
>> Received: Wed, 30 Apr 2008 10:39:11 AM CDT
>> From: Jason Pruim
>> To: Stut Cc: php-db@lists.php.net
>> Subject: Re: [PHP-DB] Timestamps
>>
>>
>> On Apr 30, 2008, at 11:35 AM, Stut wrote:
>>
>>> On 30 Apr 2008, at 16:29, Jason Pruim wrote:
>>>> Okay... So I know this should be simple...
>>>>
>>>> Trying to store a timestamp in a MySQL database... The timestamp I
>>>> am making like so: $modifiedTimestamp = time();
>>>>
>>>> and then just $sql = "Update `mytable` set
>>>> timestamp='$modifiedTimestamp' where Record='1'";
>>>>
>>>> Simple right? Not quite...in my database it's storing a "0" in the
>>>> timestamp field which is a int(10) field.
>>>>
>>>> I have googled, and searched manuals, but have not been able to
>>>> figure out what is going on....
>>>>
>>>> Any Ideas?
>>>
>>> timestamp is a reserved word. Try putting it in backticks.
>>
>>
>> Okay, so I did a really crappy job at my sudo code... The field name
>> is actually Last_Updated.
>>
>> so my update code looks like this: Last_Updated='$modifiedTimestamp'
>>
>> *Slaps his wrist... Bad copy/paste! BAD!!!
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Timestamps
am 01.05.2008 14:56:57 von Jason Pruim
On Apr 30, 2008, at 5:03 PM, Philip Thompson wrote:
> On Apr 30, 2008, at 10:54 AM, Jason Pruim wrote:
>> Hi Yves,
>>
>> Thanks for the tip, that worked, I think I'll use that from now on..
>>
>> Just out of curiosity though, any idea why it wasn't working as I
>> was writing it :)
>
> Did you try putting the query that PHP is generating in phpMyAdmin
> or MySQL Query Browser? See if it throws an error when attempting to
> update. It *appears* that the query should work.
No I haven't, I don't have phpMyAdmin installed since I do it all from
the command line, and I don't pay for hosting yet... But I am going to
need to change that. I don't believe I have heard about MySQL Query
Browser though... Is it a webapp? Or do I need to install it on my
local computer?
>
>
> ~Philip
>
> PS... Was it you, Jason, or someone else who asked about the
> security of the community knowing their database structure and I
> encouraged the use of `backticks` around all field and table names?
Yeah it was me... Old habits die hard :) I'm working on converting
everything :)
>
>
>
>> On Apr 30, 2008, at 11:47 AM, YVES SUCAET wrote:
>>
>>> Hi Jason,
>>>
>>> It's not because you create a date/time value that you
>>> automatically have an
>>> integer-value. You need to specify first that you want the date/
>>> time value
>>> converted to an integer value first.
>>>
>>> See
>>> http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functio ns.html#function_unix-timestamp
>>> for an example of how to do this.
>>>
>>> Actually, by using this function, you probably don't even need to
>>> create the
>>> $modifiedTimestamp variable anymore. You can just write your SQL
>>> query as
>>> follows:
>>>
>>> $sql = "Update `mytable` set timestamp=UNIX_TIMESTAMP() where
>>> Record='1'";
>>>
>>> HTH,
>>>
>>> Yves
>>>
>>> ------ Original Message ------
>>> Received: Wed, 30 Apr 2008 10:39:11 AM CDT
>>> From: Jason Pruim
>>> To: Stut Cc: php-db@lists.php.net
>>> Subject: Re: [PHP-DB] Timestamps
>>>
>>>
>>> On Apr 30, 2008, at 11:35 AM, Stut wrote:
>>>
>>>> On 30 Apr 2008, at 16:29, Jason Pruim wrote:
>>>>> Okay... So I know this should be simple...
>>>>>
>>>>> Trying to store a timestamp in a MySQL database... The timestamp I
>>>>> am making like so: $modifiedTimestamp = time();
>>>>>
>>>>> and then just $sql = "Update `mytable` set
>>>>> timestamp='$modifiedTimestamp' where Record='1'";
>>>>>
>>>>> Simple right? Not quite...in my database it's storing a "0" in the
>>>>> timestamp field which is a int(10) field.
>>>>>
>>>>> I have googled, and searched manuals, but have not been able to
>>>>> figure out what is going on....
>>>>>
>>>>> Any Ideas?
>>>>
>>>> timestamp is a reserved word. Try putting it in backticks.
>>>
>>>
>>> Okay, so I did a really crappy job at my sudo code... The field name
>>> is actually Last_Updated.
>>>
>>> so my update code looks like this: Last_Updated='$modifiedTimestamp'
>>>
>>> *Slaps his wrist... Bad copy/paste! BAD!!!
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
japruim@raoset.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Timestamps
am 01.05.2008 15:22:03 von Philip Thompson
On May 1, 2008, at 7:56 AM, Jason Pruim wrote:
>
> On Apr 30, 2008, at 5:03 PM, Philip Thompson wrote:
>
>> On Apr 30, 2008, at 10:54 AM, Jason Pruim wrote:
>>> Hi Yves,
>>>
>>> Thanks for the tip, that worked, I think I'll use that from now on..
>>>
>>> Just out of curiosity though, any idea why it wasn't working as I
>>> was writing it :)
>>
>> Did you try putting the query that PHP is generating in phpMyAdmin
>> or MySQL Query Browser? See if it throws an error when attempting
>> to update. It *appears* that the query should work.
>
> No I haven't, I don't have phpMyAdmin installed since I do it all
> from the command line, and I don't pay for hosting yet... But I am
> going to need to change that. I don't believe I have heard about
> MySQL Query Browser though... Is it a webapp? Or do I need to
> install it on my local computer?
Query Browser is part of the MySQL GUI tools. You can download them
here and use on your local computer:
http://dev.mysql.com/downloads/gui-tools/5.0.html
However, if you're using command line, then that should provide the
same error messages (if any) that may assist you.
>> ~Philip
>>
>> PS... Was it you, Jason, or someone else who asked about the
>> security of the community knowing their database structure and I
>> encouraged the use of `backticks` around all field and table names?
>
> Yeah it was me... Old habits die hard :) I'm working on converting
> everything :)
>>
>>
>>
>>> On Apr 30, 2008, at 11:47 AM, YVES SUCAET wrote:
>>>
>>>> Hi Jason,
>>>>
>>>> It's not because you create a date/time value that you
>>>> automatically have an
>>>> integer-value. You need to specify first that you want the date/
>>>> time value
>>>> converted to an integer value first.
>>>>
>>>> See
>>>> http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functio ns.html#function_unix-timestamp
>>>> for an example of how to do this.
>>>>
>>>> Actually, by using this function, you probably don't even need to
>>>> create the
>>>> $modifiedTimestamp variable anymore. You can just write your SQL
>>>> query as
>>>> follows:
>>>>
>>>> $sql = "Update `mytable` set timestamp=UNIX_TIMESTAMP() where
>>>> Record='1'";
>>>>
>>>> HTH,
>>>>
>>>> Yves
>>>>
>>>> ------ Original Message ------
>>>> Received: Wed, 30 Apr 2008 10:39:11 AM CDT
>>>> From: Jason Pruim
>>>> To: Stut Cc: php-db@lists.php.net
>>>> Subject: Re: [PHP-DB] Timestamps
>>>>
>>>>
>>>> On Apr 30, 2008, at 11:35 AM, Stut wrote:
>>>>
>>>>> On 30 Apr 2008, at 16:29, Jason Pruim wrote:
>>>>>> Okay... So I know this should be simple...
>>>>>>
>>>>>> Trying to store a timestamp in a MySQL database... The
>>>>>> timestamp I
>>>>>> am making like so: $modifiedTimestamp = time();
>>>>>>
>>>>>> and then just $sql = "Update `mytable` set
>>>>>> timestamp='$modifiedTimestamp' where Record='1'";
>>>>>>
>>>>>> Simple right? Not quite...in my database it's storing a "0" in
>>>>>> the
>>>>>> timestamp field which is a int(10) field.
>>>>>>
>>>>>> I have googled, and searched manuals, but have not been able to
>>>>>> figure out what is going on....
>>>>>>
>>>>>> Any Ideas?
>>>>>
>>>>> timestamp is a reserved word. Try putting it in backticks.
>>>>
>>>>
>>>> Okay, so I did a really crappy job at my sudo code... The field
>>>> name
>>>> is actually Last_Updated.
>>>>
>>>> so my update code looks like this:
>>>> Last_Updated='$modifiedTimestamp'
>>>>
>>>> *Slaps his wrist... Bad copy/paste! BAD!!!
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Timestamps
am 02.05.2008 02:31:28 von dmagick
>> PS... Was it you, Jason, or someone else who asked about the security
>> of the community knowing their database structure and I encouraged the
>> use of `backticks` around all field and table names?
>
> Yeah it was me... Old habits die hard :) I'm working on converting
> everything :)
A little caveat with that:
1) it's mysql specific
2) I can disable you using backticks
http://www.php.net/manual/en/language.operators.execution.ph p
--
Postgresql & php tutorials
http://www.designmagick.com/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Timestamps
am 02.05.2008 02:41:06 von dmagick
Chris wrote:
>>> PS... Was it you, Jason, or someone else who asked about the security
>>> of the community knowing their database structure and I encouraged the
>>> use of `backticks` around all field and table names?
>> Yeah it was me... Old habits die hard :) I'm working on converting
>> everything :)
>
> A little caveat with that:
>
> 1) it's mysql specific
> 2) I can disable you using backticks
>
> http://www.php.net/manual/en/language.operators.execution.ph p
Actually it doesn't, because the backtick is in a string.
Sorry for the noise..
--
Postgresql & php tutorials
http://www.designmagick.com/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Timestamps
am 02.05.2008 15:00:41 von Jason Pruim
On May 1, 2008, at 8:31 PM, Chris wrote:
>
>>> PS... Was it you, Jason, or someone else who asked about the
>>> security
>>> of the community knowing their database structure and I encouraged
>>> the
>>> use of `backticks` around all field and table names?
>>
>> Yeah it was me... Old habits die hard :) I'm working on converting
>> everything :)
>
> A little caveat with that:
>
> 1) it's mysql specific
Currently the system is just running on my server, and probably always
will... so I'm not too worried about it being mysql specific.
>
> 2) I can disable you using backticks
>
> http://www.php.net/manual/en/language.operators.execution.ph p
I'll have to take a look at that and see what it says in a little bit.
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
japruim@raoset.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Timestamps
am 02.05.2008 17:09:50 von Philip Thompson
On May 2, 2008, at 8:00 AM, Jason Pruim wrote:
> On May 1, 2008, at 8:31 PM, Chris wrote:
>
>>>> PS... Was it you, Jason, or someone else who asked about the
>>>> security
>>>> of the community knowing their database structure and I
>>>> encouraged the
>>>> use of `backticks` around all field and table names?
>>>
>>> Yeah it was me... Old habits die hard :) I'm working on converting
>>> everything :)
>>
>> A little caveat with that:
>>
>> 1) it's mysql specific
>
> Currently the system is just running on my server, and probably
> always will... so I'm not too worried about it being mysql specific.
So is the query (mysql-specific). If you change to another *SQL, then
you'll probably have to change the query anyway, so the backticks are
not the biggest issue and they'll help you in the meantime.
>> 2) I can disable you using backticks
>>
>> http://www.php.net/manual/en/language.operators.execution.ph p
>
> I'll have to take a look at that and see what it says in a little bit.
As you mentioned Chris, the backticks are in a string, so there's not
a security risk in this method.
~Philip
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php