Home > Archive > PHP SQL > April 2004 > problem inserting a new row to a table.
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
problem inserting a new row to a table.
|
|
| davidklonski 2004-04-10, 1:31 pm |
| Hello
I have the following table definition:
CREATE TABLE `session_info_tbl` (
`UserID` int(11) NOT NULL default '0',
`Expiration` timestamp(14) NOT NULL,
`IndividualsLastQuery` varchar(255) NOT NULL default '',
PRIMARY KEY (`UserID`)
) TYPE=MyISAM;
I am trying to add a new row to the table with the following command:
INSERT INTO session_info_tbl (UserID, Expiration,
IndividualsLastQuery) VALUES ('test', 1081623606,
'');
but for some reason the row that gets added is:
UserID: 0
Expiration: 00000000000000
IndividualsLastQuery:
What am I doing wrong?
I know the following the the MySQL spec:
Illegal DATETIME, DATE, or TIMESTAMP values are converted to the
``zero'' value of the appropriate type ('0000-00-00
00:00:00', '0000-00-00', or 00000000000000).
Why is my timestamp wrong? and even if it is wrong, why wasn't the
userID field set appropriately?
I am doing it in PHP and mysql_query() returns true. So there was no
error in the query.
thanks in advance
----------------------------------------
The post originated from PHP Freaks:
----------------------------------------
http://www.phpfreaks.com
http://www.phpfreaks.com/forums
| |
| Joachim Mæland 2004-04-10, 6:31 pm |
| On Sat, 10 Apr 2004 11:25:22 -0500, davidklonski wrote:
> CREATE TABLE `session_info_tbl` (
> `UserID` int(11) NOT NULL default '0',
> `Expiration` timestamp(14) NOT NULL,
> `IndividualsLastQuery` varchar(255) NOT NULL default '',
> PRIMARY KEY (`UserID`)
> ) TYPE=MyISAM;
[..]
> INSERT INTO session_info_tbl (UserID, Expiration, IndividualsLastQuery)
> VALUES ('test', 1081623606, '');
>
> but for some reason the row that gets added is: UserID: 0
> Expiration: 00000000000000
> IndividualsLastQuery:
> `UserID` int(11) NOT NULL default '0',
'test' is not an integer...
Timestamps are handled automaticly by MySQL and there is no need to address
it in your query.
--
mvh/regards
Joachim Mæland
If everything seems under control, you're just not going fast enough.
-Mario Andretti
| |
|
| davidklonski wrote:
| Hello
|
| I have the following table definition:
|
| CREATE TABLE `session_info_tbl` (
| `UserID` int(11) NOT NULL default '0',
| `Expiration` timestamp(14) NOT NULL,
| `IndividualsLastQuery` varchar(255) NOT NULL default '',
| PRIMARY KEY (`UserID`)
| ) TYPE=MyISAM;
|
| I am trying to add a new row to the table with the following command:
|
| INSERT INTO session_info_tbl (UserID, Expiration,
| IndividualsLastQuery) VALUES ('test', 1081623606,
| '');
|
| but for some reason the row that gets added is:
| UserID: 0
| Expiration: 00000000000000
| IndividualsLastQuery:
|
| What am I doing wrong?
| I know the following the the MySQL spec:
| Illegal DATETIME, DATE, or TIMESTAMP values are converted to the
| ``zero'' value of the appropriate type ('0000-00-00
| 00:00:00', '0000-00-00', or 00000000000000).
| Why is my timestamp wrong? and even if it is wrong, why wasn't the
| userID field set appropriately?
| I am doing it in PHP and mysql_query() returns true. So there was no
| error in the query.
|
Hi,
mysql> CREATE TABLE `session_info_tbl` (
-> `userid` INT NOT NULL AUTO_INCREMENT ,
-> `expiration` TIMESTAMP( 14 ) NOT NULL ,
-> `individualslastquery` VARCHAR( 255 ) NOT NULL ,
-> PRIMARY KEY ( `userid` )
-> );
Query OK, 0 rows affected (0.02 sec)
mysql> INSERT INTO `session_info_tbl`
->( `userid` , `expiration` , `individualslastquery` )
-> VALUES ('', NOW( ) , '1081623606'
-> );
Query OK, 1 row affected (0.01 sec)
mysql> select * from session_info_tbl;
+--------+----------------+----------------------+
| userid | expiration | individualslastquery |
+--------+----------------+----------------------+
| 1 | 20040410224345 | 1081623606 |
+--------+----------------+----------------------+
1 row in set (0.00 sec)
mysql>
|
|
|
|
|