코드가 정상적으로 작동합니다. 나는 우분투 상자를 사용하고 있기 때문에 테이블 이름을 대문자로 사용합니다.
SOURCE
<?php
$user = "root";
$pwd = "root123";
$db_con = mysql_connect($server,$user,$pwd);
$select_db = mysql_select_db("ci",$db_con);
$txnid = date ("ydmHis") . mt_rand(1000, 9999);
$custnumber = "4316010100000001";
$cust_mo_num = "7875432990";
$bc_id = "LTH001";
$timestamp = "12:12:12:12:12:12";
$amounta = "500";
$txnupdate = "INSERT INTO CUST_TXN (txnid,cust_num,cust_mo_num,bc_username,txn_time,txn_amount,txn_type,txn_status) VALUES ('$txnid','$custnumber','$cust_mo_num','$bc_id','$timestamp','$amounta','WTH','SUCC')";
echo $txnupdate;
$result = mysql_query($txnupdate);
mysql_close($db_con);
echo $result;
?>
> select * from CUST_TXN;
+------------------+------------------+-------------+-------------+-------------------+------------+----------+------------+
| txnid | cust_num | cust_mo_num | bc_username | txn_time | txn_amount | txn_type | txn_status |
+------------------+------------------+-------------+-------------+-------------------+------------+----------+------------+
| 1209042028162311 | 4316010100000001 | 7875432990 | LTH001 | 12:12:12:12:12:12 | 500 | WTH | SUCC |
| 1209042028177407 | 4316010100000001 | 7875432990 | LTH001 | 12:12:12:12:12:12 | 500 | WTH | SUCC |
| 1209042028194204 | 4316010100000001 | 7875432990 | LTH001 | 12:12:12:12:12:12 | 500 | WTH | SUCC |
| 1209042028342444 | 4316010100000001 | 7875432990 | LTH001 | 12:12:12:12:12:12 | 500 | WTH | SUCC |
| 1209042028358383 | 4316010100000001 | 7875432990 | LTH001 | 12:12:12:12:12:12 | 500 | WTH | SUCC |
| 1209042028362068 | 4316010100000001 | 7875432990 | LTH001 | 12:12:12:12:12:12 | 500 | WTH | SUCC |
+------------------+------------------+-------------+-------------+-------------------+------------+----------+------------+
또한 당신은 당신의 txn_time 열
MYSQL에 대한 CURRENT_TIMESTAMP를 사용할 수있는 결과 (귀하의 CUST_TXN 테이블 이름으로 제공 테이블 문을 작성) DDL
CREATE TABLE CUST_TXN_2 (txnid char(16), PRIMARY KEY(txnid), cust_num char(16), cust_mo_num char(10), bc_username char(6), txn_time timestamp DEFAULT CURRENT_TIMESTAMP, txn_amount varchar(10), txn_type varchar(5), txn_status varchar(10));
SOURCE
<?php
$user = "root";
$pwd = "root123";
$db_con = mysql_connect($server,$user,$pwd);
$select_db = mysql_select_db("ci",$db_con);
$txnid = date ("ydmHis") . mt_rand(1000, 9999);
$custnumber = "4316010100000001";
$cust_mo_num = "7875432990";
$bc_id = "LTH001";
$amounta = "500";
$txnupdate = "INSERT INTO CUST_TXN_2 (txnid,cust_num,cust_mo_num,bc_username,txn_amount,txn_type,txn_status) VALUES ('$txnid','$custnumber','$cust_mo_num','$bc_id','$amounta','WTH','SUCC')";
echo $txnupdate;
$result = mysql_query($txnupdate);
mysql_close($db_con);
echo $result;
?>
는
> select * from CUST_TXN_2;
+------------------+------------------+-------------+-------------+---------------------+------------+----------+------------+
| txnid | cust_num | cust_mo_num | bc_username | txn_time | txn_amount | txn_type | txn_status |
+------------------+------------------+-------------+-------------+---------------------+------------+----------+------------+
| 1209042055524683 | 4316010100000001 | 7875432990 | LTH001 | 2012-04-09 20:55:52 | 500 | WTH | SUCC |
| 1209042055563581 | 4316010100000001 | 7875432990 | LTH001 | 2012-04-09 20:55:56 | 500 | WTH | SUCC |
| 1209042055564435 | 4316010100000001 | 7875432990 | LTH001 | 2012-04-09 20:55:56 | 500 | WTH | SUCC |
| 1209042055579931 | 4316010100000001 | 7875432990 | LTH001 | 2012-04-09 20:55:57 | 500 | WTH | SUCC |
+------------------+------------------+-------------+-------------+---------------------+------------+----------+------------+
"(txnid는 기본 키이며 매번 변경합니다.)"그렇다면 게시 한 코드가 실행중인 코드와 다릅니다. 분명히 게시 한 코드는 작동하지 않습니다. 그러나 게시 한 코드와 다른 점을 알지 못하면 실제 코드에서 문제를보기가 약간 어려울 수 있습니다. 실제 코드를 게시 할 수 있습니까? –
타임 스탬프가 이상하게 보입니다. –
mysql 콘솔에서 아래 명령을 실행 한 후 create table statement를 게시하십시오. show create table cust_txn; –