错误:
致命错误:调用非对象中的成员函数query() .... Rrgister.php 9
我的Register.php文件是
<?php
require "conn.php";
$name=$_POST["name"];
$surname=$_POST["surname"];
$age=$_POST["age"];
$user_name=$_POST["user_name"];
$user_pass=$_POST["password"];
$mysql_qry="insert into candidates(name,surname,age,user_name,user_pass) values('$name','$surname','$age','$user_name','$user_pass')";
if($conn->query($mysql_qry)=== TRUE){
echo "Insert Successfull";
}
else
{
echo "Error".$mysql_qry."<br>".$conn->error;
}
$conn->close();
?>
我的conn.php
<?php
$db_name="candidates";
$mysql_username="user";
$mysql_password="password";
$server_name=".........";
$conn = mysqli_connect($server_name, $mysql_username, $mysql_password,$db_name);
?>
答案 0 :(得分:0)
如果使用结构连接,则应使用:
1
$result = mysqli_query($conn, "Your query");
如果你使用对象连接,那么:
2
$conn->query("Your query");
似乎你是通过程序连接的,所以试试第一个例子并阅读 - http://php.net/manual/en/mysqli.query.php