可以';t向数据库中添加行


can't add a row to database

我刚刚写了一个简单的代码,将一行插入到我的数据库中,称为概要文件,但它不起作用。

代码:

<?php   
      $mysqli= new mysqli("localhost", "****", "****", "****");
        if (mysqli_connect_errno()) {
            throw new Exception("Unable to connect to the database. Error number: " . $this->mysqli->connect_errno);
    }
    $result = mysqli_query($mysqli,"INSERT INTO 'profiles' VALUES ( aaa , aaa , aaa , aaa , aaa , aaa , 1 , 1 , 0 , aaa , 0 )");
        if($mysqli->affected_rows <= 0){
            throw new Exception("Unable to add record in the database! Query returned: " . $result);
    }
    echo "1";
?>   

我的数据库:

1   username    varchar(20) 
2   password    varchar(200)    
3   email   varchar(20) 
4   name    varchar(20) 
5   city    varchar(200)    
6   address varchar(200)    
7   mf  varchar(5)  
8   pp  varchar(5)  
9   reputation  varchar(20) 
10  register_date   varchar(20)
11  kh_f varchar(5)

以及错误日志:

[18-Jul-2014 12:32:50 UTC] PHP Fatal error:  Uncaught exception 'Exception' with message 'Unable to add record in the database! Query returned: ' in /home/***/***/***/**/test.php:9
Stack trace:
#0 {main}
  thrown in /home/***/***/***/**/test.php on line 9

提前感谢!

请使用mysqli_error()获取您的错误;(

并在字符串中添加引号:$result = mysqli_query($mysqli,"INSERT INTO profiles VALUES ( 'aaa' , 'aaa' , 'aaa' , 'aaa' , 'aaa' , 'aaa' , '1' , '1' , '0' , 'aaa' , '0' )");

"INSERT INTO 'profiles' VALUES ..."

不是'profiles',而是profiles,带有位于1(!)左侧的按钮,我不能写这个符号,因为bbcode将其解析为代码