sql语法错误[关闭]

sql语法错误[关闭]

问题描述:

i tried without single quotes and with it does not work.

$insert_query="INSERT INTO users_line
(name,surname,company_name,tel_number,cell_number,email,location,main_image,about_us)


VALUES('$name','$surname','$company_name','$tel_number','$cell_number','$email','$location','$main_image','$about_us')";
    if(mysqli_query($connect,$insert_query==true)){
        echo " <script>alert('successfully Posted') </script> ";

    } else{ echo  " h1> Did not work </h1>";

try

$connect->query($insert_query) to run the query.

Try this.

$insert_query="INSERT INTO
users_line        (name,surname,company_name,tel_number,cell_number,email,location,main_image,about_us)
VALUES('$name', '$surname','$company_name', '$tel_number', '$cell_number', '$email', '$location', '$ main_image', '$about_us')";

mysqli_query($connect,$insert_query);
 if(mysqli_affected_rows($connection) > 0){
 echo "It is working";
 }
 else{
 echo "Not Working!";

You had echo " h1> Did not work </h1>"; that should be echo "<h1> Did not work </h1>";