夜间福利网站,免费动漫av,一级做a爰片久久毛片免费陪,夜夜骑首页,黄色毛片视频,插插插操操操,综合av色

PHP怎么插入數(shù)據(jù)庫

時間:2025-12-30 16:02:02 php語言

PHP怎么插入數(shù)據(jù)庫

  導(dǎo)語:PHP這么鏈接數(shù)據(jù)庫呢?以下的是百分網(wǎng)小編為大家搜集PHP插入數(shù)據(jù)庫的方法,希望對你有所幫助。

  $ostype=$_POST['ostype'];

  $uuid=$_POST['uuid'];

  $nowtime=time();

  $username='XXXX';

  $userpass='XXXX';

  $dbhost='localhost';

  $dbdatabase='XXX';

  /pic/p>

  $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'=>'鏈接數(shù)據(jù)庫失敗');

  }

  else {

  mysql_select_db($dbdatabase,$db_connect);

  $result = mysql_query("INSERT INTO t_dblocal_userinformation (ID, OSTYPE, UUID, LASTDATE) VALUES (NULL, $ostype, $uuid, $nowtime)");

  if ($result) {

  $ret_json=array('code'=>1000, 'message'=>'插入數(shù)據(jù)庫成功');

  }

  else {

  $ret_json=array('code'=>1002, 'message'=>'插入數(shù)據(jù)庫失敗');

  }

  }

  $jobj=new stdclass();

  foreach($ret_json as $key=>$value){

  $jobj->$key=$value;

  }

  echo ''.json_encode($jobj);

  ?>

  為嘛插入數(shù)據(jù)庫失敗呢??

  ID是自增的主鍵,LASTDATE是DATE類型

  ------解決方案--------------------

  報錯提示什么?

  如果LASTDATE是DATE類型 $nowtime=date(‘Y-m-d’);

  如果LASTDATE是DATETIME類型$nowtime=date(‘Y-m-d H:i:s');

  ------解決方案--------------------

  echo mysql_error(); 報什么錯誤沒有

  ------解決方案--------------------

  少了引號了。

  $result = mysql_query("INSERT INTO t_dblocal_userinformation (ID, OSTYPE, UUID, LASTDATE) VALUES (NULL, '$ostype', '$uuid', '$nowtime')");

  ------解決方案--------------------

  引用:

  少了引號了。

  $result = mysql_query("INSERT INTO t_dblocal_userinformation (ID, OSTYPE, UUID, LASTDATE) VALUES (NULL, '$ostype', '$uuid', '$nowtime')");同意

  ------解決方案--------------------

  第一個 想樓上那樣說的 引號的問題

  第二個 你的time()是返回的時間戳,和date類型對應(yīng)不上吧 要轉(zhuǎn)化處理一下才行

【PHP怎么插入數(shù)據(jù)庫】相關(guān)文章:

PHP如何插入數(shù)據(jù)庫03-09

PHP插入數(shù)據(jù)庫的方法03-12

PHP大批量插入數(shù)據(jù)庫的方法01-05

PHP大批量插入數(shù)據(jù)庫的3種方法11-21

PH如何插入數(shù)據(jù)庫02-17

PHP訪問數(shù)據(jù)庫11-12

怎么用php去調(diào)用數(shù)據(jù)庫里面的數(shù)據(jù)12-05

php數(shù)據(jù)庫備份腳本11-20

PHP如何創(chuàng)建數(shù)據(jù)庫12-20