这是我的PHP代码,它不插入记录并始终显示 false 。
$con = mysqli_connect("localhost", "XXX", "XXX", "vital");
$fieldName = implode(",",array_keys($data));
$values = '"'.implode('","', array_values($data)).'"';
echo $query = "insert into ".$table." (".$fieldName.") values(".$values.")";
if(mysqli_query($con,$query))
echo "<br>true";
else
echo "<br>false";
它是等同的SQL查询,我直接写入phpmyadmin,这是完美的工作。下面是由echo $query
insert into patient
(patient_id,opd_id,patient_name,hospital_name,plot_from_file,entry_date)
values("1234","1233","456","temp","false","2014-08-20");
以上查询将在phpmyadmin中完美运行。
答案 0 :(得分:-3)
请尝试这个
`<?php
$con=mysql_connect("localhost","xxx","xxx");
if(!$con)
{
die("could not connect".mysql_error());
}
mysql_select_db("DB Name",$con);
?>`
<?php
$sql="INSERT INTO patient
(patient_id,opd_id,patient_name,hospital_name,plot_from_file,entry_date)
values("1234","1233","456","temp","false","2014-08-20"); ?>