初学者,    
parse error: syntax error, unexpected t_variable in c:\appserv\www\form_write_mysql\add.php on line 7   
line 7    
就是这句    $sql = insert into users(username, email) values('$_post[username]', '$_post[email]');      
我这个页面很简单,就是login.php 页面上的form 提交到 add.php,  其中引用 conn。php 来连接mysql
然后 把数据(useranme,email) 写入到  mysql 上的 company  db的users (username,email)表上
==============================================================   
login.php
name:
email:
add.php
$conn = new mysqli(localhost, root, 123123);   
$conn->select_db(company);   
//mysql_query(set name 'gb2312');   
$conn->set_charset(utf8);
回复讨论(解决方案)   期待有人回答中。。。 
   把sql,输出,看看是什么  
也没有转义,是不是输入了单引号? 
   if(isset($_post[submit])){  
$sql = insert into users(username, email) values('$_post[username]', '$_post[email]');  
mysqli_query($conn, $sql);  
echo 添加成功;  
}
把这几行前面的全角空格换成英文空格 
   $sql = insert into users(username, email) values('$_post[username]', '$_post[email]');  
mysqli_query($conn, $
第二行mysql 多了个 i  啊 
   $_post[username]应该加引号  ====》$_post[‘username’]  同理email也是 
   打印$sql就知道sql语句有没有问题了
if(isset($_post[submit])){   
$sql = insert into users(username, email) values('$_post[username]', '$_post[email]');   
mysqli_query($conn, $sql);   
echo 添加成功;   
}
把这几行前面的全角空格换成英文空格
guoran nb  
fatal error: call to undefined function ¡¡¡¡include() in c:\appserv\www\form_write_mysql\add.php on line 3  
hehe queshi zhege yuanying  
  $conn = new mysqli(localhost, root, 123123); $conn->select_db(company); //mysql_query(set name 'gb2312'); $conn->set_charset(utf8);   
warning: mysqli_query() expects parameter 1 to be mysqli, null given in c:\appserv\www\form_write_mysql\add.php on line 8  
添加成功
实际上这个 $conn , 已经正确使用了,但是 我在 add。php 中   
echo $conn.'
';  
却没有输出结果 ,这是为什么呢?   
@jordan102
include 前面同样有全角空格。  
既然用面向对象方式连接数据库了,为什么不用面向对象方式执行sql呢。  
$conn->query($sql); 
   add.php 里面mysql语句错了,原句mysqli_query($con你,      改成mysql_query($con你, 
   还不结贴啊 。
   
 
   