遇到了这样的错误:
Undefined variable: conn on line 33
Fatal error: Uncaught Error: Call to a member function close() on null
代码如下
<link rel="stylesheet" href="course.css">
<?php
$title = "College";
include('include/header.inc');
?>
<h1>College</h1>
<?php
include('include/nav.inc');
?>
<?php
if (!empty($_GET['id'])) {
include('include/db_connect.inc');
$name = $_GET['courseid'];
$sql = "select * from CourseDetails where courseid = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $name);
$name = $_GET['courseid'];
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
while ($row = mysqli_fetch_array($result)) {
print "<h2>{$row['coursecode']}</h2>";
print "<h3>by {$row['name']}</h3>";
print "<h4>{$row['subject']}</h4>";
print "<h5>{$row['instuctors']}</h5>";
print "<h6>{$row['weeks']}</h6>";
print "<p>{$row['description']}</p>";
}
}
}
?>
<?php
$conn->close();
include('include/footer.inc');
?>
具体报什么错误呢?把错误信息贴出来看看
您好,我是有问必答小助手,你的问题已经有小伙伴为您解答了问题,您看下是否解决了您的问题,可以追评进行沟通哦~
如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~
ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632
错误是这样的
非常感谢您使用有问必答服务,为了后续更快速的帮您解决问题,现诚邀您参与有问必答体验反馈。您的建议将会运用到我们的产品优化中,希望能得到您的支持与协助!
速戳参与调研>>>https://t.csdnimg.cn/Kf0y
对null上的成员函数close()的调用
php代码 给一个函数 public function clone(){
里面写你的代码
}
$this->clone();