开发者

Why is this simple SQL and PHP thing not working?

开发者 https://www.devze.com 2023-02-11 08:44 出处:网络
This is the code - if(empty($errors)) { mysqli_select_db($connect,\"users\"); $i=\"insert into people (serial,name,price,desc) values (\'\',\'$name\',\'$price\',\'$desc\')\";

This is the code -

if(empty($errors))
{
    mysqli_select_db($connect,"users");
    $i  =  "insert into people (serial,name,price,desc) values ('','$name','$price','$desc')";
    $qs  = mysqli_query($connect,$i);

    if($qs)
    {
     开发者_Python百科   echo "Awesome";
    }
    else
    {
        echo "geez";
    }
}

it is always displaying geez.


One problem is that desc is a reserved word so you must use backticks when using it as a column name:

INSERT INTO people (serial, name, price, `desc`) VALUES ...


echo mysqli_error

and you go...................

0

精彩评论

暂无评论...
验证码 换一张
取 消