sql语法错误

时间:2014-05-30 09:08:29

标签: php mysql sql

我尝试没有单引号,但它不起作用。

$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>";

2 个答案:

答案 0 :(得分:0)

$connect->query($insert_query)运行查询。

答案 1 :(得分:0)

试试这个。

$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!";

您的echo " h1> Did not work </h1>";应为echo "<h1> Did not work </h1>";