我正在尝试从 PHP 代码将数据插入到 mySQL 查询中。代码执行没有任何错误,但不会将数据插入数据库。有什么问题?提前致谢。
<?php
include 'dbc.php';
$sql="INSERT INTO `realtorl_leads`.`data` (`LeadFirstName`, `LeadLastName`, `LeadEmail`, `LeadEmail2`, `LeadPhone`, `LeadCity`, `LeadAddress`, `LeadPostcode`, `LeadUserId`, `LeadLeadStatusId`, `LeadMonth`, `LeadAreas`, `LeadMinPrice`, `LeadMaxPrice`, `LeadMinBedrooms`, `LeadMaxBedrooms`, `LeadMinBathrooms`, `LeadMaxBathrooms`, `LeadMinYear`, `LeadNextFollowup_mm`, `LeadNextFollowup_dd`, `LeadNextFollowup`) VALUES ('x', 'y', 'x@ff.com', 'y@ff.com', '3242342', 'karachi', '3234asdasd.karachi', '74600', '222', '32432', '23', '232', '232', '23', '232', '323', '323', '232', '23232', '3232', '232', '23232')";
?>
编辑:
我现在有以下代码,执行的代码只显示一个新行和文本说它不起作用。请指导。
<?php
include 'dbc.php';
$LeadFirstName = $_POST['LeadFirstName'];
$LeadFirstName = $_POST['LeadFirstName'];
$LeadEmail =$_POST['LeadEmail'];
$LeadEmail2 =$_POST['LeadEmail2'];
$LeadPhone =$_POST['LeadPhone'];
$LeadCity =$_POST['LeadCity'];
$LeadAddress =$_POST['LeadAddress'];
$LeadPostcode =$_POST['LeadPostcode'];
$LeadUserId =$_POST['LeadUserId'];
$LeadLeadStatusId =$_POST['LeadLeadStatusId'];
$LeadMonth =$_POST['LeadMonth'];
$LeadAreas =$_POST['LeadAreas'];
$LeadMinPrice =$_POST['LeadMinPrice'];
$LeadMaxPrice =$_POST['LeadMaxPrice'];
$LeadMinBedrooms =$_POST['LeadMinBedrooms'];
$LeadMaxBedrooms =$_POST['LeadMaxBedrooms'];
$LeadMinBathrooms =$_POST['LeadMinBathrooms'];
$LeadMaxBathrooms =$_POST['LeadMaxBathrooms'];
$LeadMinYear =$_POST['LeadMinYear'];
$LeadNextFollowup_mm =$_POST['LeadNextFollowup_mm'];
$LeadNextFollowup_dd =$_POST['LeadNextFollowup_dd'];
$LeadNextFollowup =$_POST['LeadNextFollowup'];
$sql="INSERT INTO 'realtorl_leads'.`data (`LeadFirstName`, `LeadLastName`, `LeadEmail`, `LeadEmail2`, `LeadPhone`, `LeadCity`, `LeadAddress`, `LeadPostcode`, `LeadUserId`, `LeadLeadStatusId`, `LeadMonth`, `LeadAreas`, `LeadMinPrice`, `LeadMaxPrice`, `LeadMinBedrooms`, `LeadMaxBedrooms`, `LeadMinBathrooms`, `LeadMaxBathrooms`, `LeadMinYear`, `LeadNextFollowup_mm`, `LeadNextFollowup_dd`, `LeadNextFollowup`) VALUES ($LeadFirstName, $LeadLastName, $LeadEmail, $LeadEmail2, $LeadPhone, $LeadCity, $LeadAddress, $LeadPostcode, $LeadUserId, $LeadLeadStatusId, $LeadMonth, $LeadAreas, $LeadMinPrice, $LeadMaxPrice, $LeadMinBedrooms, $LeadMaxBedrooms, $LeadNextFollowup_mm, $LeadNextFollowup_dd, $LeadNextFollowup)";
$result = mysql_query($sql);
echo($result."<br>");
if (mysql_affected_rows($result)){
echo("worked");
}else {
echo("does not work");
}
?>