插入在採集值 =>使用項目 然後我已創建的集合 => db.createCollection(「WaterMoneteringSystem」,{封端:真,尺寸: 2147483648,最大:20000})mongodb的並用的MongoDB 連接我已創建數據庫項目後用PHP
然後我想通過PHP 輸入值到集合,所以這是我寫
<?php
$d=$_POST['dte'];
$t=$_POST['tme'];
$PH=$_POST['ph'];
$TU=$_POST['tbdity'];
$RO=$_POST['RdcdOxdtn'];
if($PH>14 || $PH<0)
{
echo "error";
}
else
{
$m = new MongoClient();
echo "Connection to database successfully";
select a database
$db = $m->project;
echo "Database project selected";
$collection = $db->WaterMoneteringSystem;
echo "Collection selected succsessfully";
$document = array(
"Date" => "$d",
"Time" => "$t",
"PH" => "$PH",
"Turbidity" => "$TU",
"Reduced Oxidation" =>"$RO"
);
$collection->insert($document);
echo "Document inserted successfully";
}
?>
代碼但這不是工作
謝謝
你會得到什麼錯誤? –
你是否在你的'$ _POST'變量中得到任何數據?另外,'select a database'行沒有被註釋掉,所以會引發錯誤。 – Quixrick
這些值不在集合中。 –