变量那里加上花括号({})即可。$add = "insert into admin(adminid,adminname,password,rolename) values('{$adminid}','{$adminname}','{$password}','{$rolename}')";把第一行与第二行改为:$conn = mysqli_connect('localhost','root','root','news');mysqli_connect的第四个参数就是库名。