无法为我的数据库执行INSERT查询(未显示错误)

时间:2019-04-03 15:07:19

标签: php mysql

所以我尝试调试了很长时间,但是找不到问题,也许我的代码已经搞混了,这是我第一次尝试这样做,所以请放心我;)

我认为问题出在我的INSERT上,因为我已连接到服务器。

$email = $db_select->real_escape_string($_POST['email']);
$terms = $db_select->real_escape_string($_POST['terms']);
$sendEmail = $db_select->real_escape_string($_POST['sendEmail']);
$phone = $db_select->real_escape_string($_POST['phone']);
$lastName = $db_select->real_escape_string($_POST['lastName']);
$gender = $db_select->real_escape_string($_POST['gender']);
$fName = $db_select->real_escape_string($_POST['fName']);
$secName = $db_select->real_escape_string($_POST['secName']);
$thridName = $db_select->real_escape_string($_POST['thridName']);
$thourthName = $db_select->real_escape_string($_POST['thourthName']);
$mFName = $db_select->real_escape_string($_POST['mFName']);
$mSecName = $db_select->real_escape_string($_POST['mSecName']);
$mThirdName = $db_select->real_escape_string($_POST['mThirdName']);
$mThourthName = $db_select->real_escape_string($_POST['mThourthName']); 


define ('DB_NAME' , '.....');
define ('DB_USER' , '.....');
define ('DB_PASSWORD' , '....');
define ('DB_HOST' , '....');

$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link){
    die('could not connect' . mysql_error());
}else{ echo "connect. " ; }


$db_select = mysql_select_db( DB_NAME , $link);
if ( !$db_select){
    die('Can\'t use: ' . DB_NAME . ':' . mysql_error());
}
else{echo "Can use DB. ";}


$sql = "INSERT INTO shemot (email , terms , sendEmail , phone , lastName , gender , fName , secName , thridName , thourthName , mFName , mSecName , mThirdName , mThourthName) 
VALUES ('$email' , '$terms' , '$sendEmail' , '$phone' , '$lastName' , '$gender' , '$fName' , '$secName' , '$thridName' , '$thourthName' , '$mFName' , '$mSecName' , '$mThirdName' , '$mThourthName')";

if(mysqli_query($db_select, $sql)){
    echo "Success!  ";
} else{
    echo "ERROR: Could not able to execute. " . mysqli_error($db_select);
}
mysqli_close($db_select);

我认为它将插入数据,但是我收到了消息

  

“错误:无法执行。”没有mysqli_error($ bd_select)部分,有什么主意吗?找了几天,试图再次从头开始。

0 个答案:

没有答案