我似乎无法解决此问题,尽管我认为这与我的语法有关。任何帮助将不胜感激。
“解析错误:语法错误,意外的',',期望第12行中的']'是显示的错误。
?php
if ( ! empty( $_POST ) ) {
$mysqli = new mysqli('localhost', '111', '111', '111' );
if ( $mysqli->connect_error ){
die('connect error: ' . $mysqli->connect_errno. ': ' . $mysqli->connect_error );
}
$sql = "INSERT INTO processcv ( Name, Surname, Tel, Email, Message, CVtype) VALUES
( '{$mysqli->cubrid_real_escape_string($_POST['Name'])}','
( '{$mysqli->cubrid_real_escape_string($_POST['Surname])}','
( '{$mysqli->cubrid_real_escape_string($_POST['Tel'])}','
( '{$mysqli->cubrid_real_escape_string($_POST['Email'])}','
( '{$mysqli->cubrid_real_escape_string($_POST['Message'])}',
( '{$mysqli->cubrid_real_escape_string($_POST['CVtype'])}' )";
$insert = $mysqli->query($sql);
if ( $insert ){
echo "success! Row ID: {$mysqli->insert_id}";
} else{
die("error: {$mysqli->errno} : {$mysqli->error}");
}
$mysqli->close();
}
?>
答案 0 :(得分:0)
他们的语法错误意外地使用了'
和称为变量的方式,请在下面检查
<?php
if ( ! empty( $_POST ) ) {
$mysqli = new mysqli('localhost', '111', '111', '111' );
if ( $mysqli->connect_error ){
die('connect error: ' . $mysqli->connect_errno. ': ' . $mysqli->connect_error );
}
$sql = "INSERT INTO processcv ( Name, Surname, Tel, Email, Message, CVtype) VALUES
( '".$mysqli->cubrid_real_escape_string($_POST['Name'])."'),
( '".$mysqli->cubrid_real_escape_string($_POST['Surname'])."'),
( '".$mysqli->cubrid_real_escape_string($_POST['Tel'])."'),
( '".$mysqli->cubrid_real_escape_string($_POST['Email'])."'),
( '".$mysqli->cubrid_real_escape_string($_POST['Message'])."'),
( '".$mysqli->cubrid_real_escape_string($_POST['CVtype'])."')";
$insert = $mysqli->query($sql);
if ( $insert ){
echo "success! Row ID: {$mysqli->insert_id}";
} else{
die("error: {$mysqli->errno} : {$mysqli->error}");
}
$mysqli->close();
}
?>