我試圖從我的表單插入一條記錄到數據庫中,但點擊提交後會顯示「您的SQL語法錯誤;檢查與您的對應的手冊MySQL服務器版本正確的語法」錯誤.... 請幫我我如何在數據庫中插入記錄
<?php
include('data_conn.php');
if(isset($_POST['subm'])){
$email = mysql_real_escape_string($_POST['email']);
$query = "SELECT * FROM login WHERE email='$email'";
$result = mysql_query($query) or die(mysql_error());
if (mysql_num_rows($result)) {
echo '<script language="javascript">';
echo 'alert("Email is Already Exist...."); location.href="signup.php"';
echo '</script>';
}
else {
$f_name = $_POST['f_name'];
$c_name = $_POST['c_name'];
$c_add = $_POST['c_add'];
$mob = $_POST['mob'];
$email = $_POST['email'];
$password = $_POST['password'];
$query = "INSERT INTO login (first_name,company_name,company_add,mob,email,password) VALUES ('$f_name,'$c_name','$c_add','$mob','$email','$password')";
$result = mysql_query($query) or die(mysql_error());
if($result==1)
{
echo '<script language="javascript">';
echo 'alert("successfully registered!!!"); location.href="signup.php"';
echo '</script>';
}
else
{
echo '<script language="javascript">';
echo 'alert("Something Went Wrong!!! :("); location.href="signup.php"';
echo '</script>';
}
}
}
?>
mysql_ *函數已過時並已從PHP 7中刪除。您應該使用更現代的庫,如mysqli或PDO – GordonM