500-Internal Server Error
。我使用的代码是:
$stmt = $conn->prepare("SELECT * FROM people WHERE name = ?");
$stmt->bind_param('s', $name);
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows):
$row = $stmt->fetch_assoc();
$id = $row['id'];
$position = $row['position'];
else:
die("User not found.");
endif;
我过去如何使用MySQL:
$sql = "SELECT * FROM people WHERE name = '$name'";
$result = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($result) > 0):
$row = mysql_fetch_array($result);
$id = $row['id'];
$position = $row['position'];
else:
die("User not found.");
endif;
任何和所有帮助将不胜感激。
编辑:以下代码位于我的文件的开头:
// Connection Details
$host = "";
$user = "";
$pass = "";
$db = "";
// Database Connection
$conn = new mysqli($host, $user, $pass, $db);
// check connection
if ($conn->connect_error) {
trigger_error('Database connection failed: ' . $conn->connect_error, E_USER_ERROR);
}
您能否告诉我复制MySQLi中发布的MySQL代码的最佳方法?