我尝试使用PHP插入mySQL数据库。我正在使用XAMPP服务器,我正在处理的项目的方式是在htdocs / proiect
php代码是
if($ok == 0){
$hostname = "localhost";
$database = "Forum";
$db_table = "Users";
$db = mysql_connect('localhost', 'root','');
mysql_select_db($database,$db);
$sql = "INSERT INTO $db_table(name,email) values (nvl(select max(user_id) from Users,0)+1,'".mysql_real_escape_string(stripslashes($_REQUEST['userTxt']))."','".mysql_real_escape_string(stripslashes($_REQUEST['passTxt'])) ."','".mysql_real_escape_string(stripslashes($_REQUEST['emailTxt']))."',sysdate,'A')";
if($result = mysql_query($sql ,$db)) {
echo '<h1>Thank you</h1>Your information has been entered into our database<br><br>';
} else {
echo "ERROR: ".mysql_error();
}
}
我得到的错误是
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'select max(user_id) from Users,0)+1,'cdscs','as','csdcsd',sysdate,'A')' at line 1
表格是