How PHP Inserts a database
$ostype =$_post[' OSType '];
$uuid =$_post[' uuid '];
$nowtime =time ();
$username = ' XXXX ';
$userpass = ' XXXX ';
$dbhost = ' localhost ';
$dbdatabase = ' XXX ';
Generate a connection
$db _connect=mysql_connect ($dbhost, $username, $userpass) or die ("Unable to connect to the mysql!");
$ret _json;
if (! $db _connect) {
$ret _json=array (' Code ' =>1001, ' message ' => ' link database failed ');
}
else {
mysql_select_db ($dbdatabase, $db _connect);
$result = mysql_query (INSERT into T_dblocal_userinformation (ID, OSType, UUID, lastdate) VALUES (NULL, $ostype, $uuid, $n Owtime) ");
if ($result) {
$ret _json=array (' Code ' =>1000, ' message ' => ' Insert database Success ');
}
else {
$ret _json=array (' Code ' =>1002, ' message ' => ' Insert database failed ');
}
}
$jobj =new Stdclass ();
foreach ($ret _json as $key => $value) {
$jobj-> $key = $value;
}
Echo '. Json_encode ($jobj);
?>
Why did you fail to insert the database??
ID is the Lastdate primary key, and the date type is
------Solution--------------------
What does the error prompt?
If Lastdate is the date type $nowtime =date (' y-m-d ');
If Lastdate is a datetime type $nowtime=date (' y-m-d h:i:s ');
------Solution--------------------
Echo Mysql_error (); Did you report anything wrong?
------Solution--------------------
The quotes are missing.
$result = mysql_query ("INSERT into T_dblocal_userinformation (ID, OSType, UUID, lastdate) VALUES (NULL, ' $ostype ', ' $uuid ' , ' $nowtime ') ");
------Solution--------------------
Reference:
The quotes are missing.
$result = mysql_query ("INSERT into T_dblocal_userinformation (ID, OSType, UUID, lastdate) VALUES (NULL, ' $ostype ', ' $uuid ' , ' $nowtime ') ");
------Solution--------------------
The first thing to say about the quotes upstairs
The second your time () is the timestamp of the return, and the date type does not correspond to the conversion process.