我正在做一个学校项目,我正在制作一个LMS(学习管理系统)。我遇到了这个奇怪的错误关于mysql数据库如何关闭。然而,我的代码中没有一部分告诉它关闭。
下面是运行的代码:
class user_class {
// Properties
private $user_sc;
public $user_name;
public $user_pw;
public $user_fn;
public $user_mn;
public $user_ln;
public $new_data;
private $query_table;
private $query_col;
private $USER_ID;
private $dbconn;
function __construct($dbconn){
$this->db = $dbconn;
}
function login($user_name,$user_pw) {
$login_info = "SELECT email, pw FROM user_info where email = '$user_name' and pw = '$user_pw'";
$result = mysqli_query($this->db, $login_info);
$count = mysqli_num_rows($result);
if($count == 1){
return $this->get_name($user_name);
}else{
return false;
}
}
}
下面是代码:
class course_class {
private $dbconn;
function __construct($dbconn){
$this->db = $dbconn;
}
function dlist($num) {
$grabdata = "SELECT * FROM couse_def";
$result = mysqli_query($this->db,$grabdata) or die("Couldn't execute query.") ;
$tablecode = "<select name='CatID'>";
//Loop through the results to manage each row
while ($row = mysqli_fetch_assoc($result))
{
$isSelected ="";
$tablecode .= "<option value='".$row['CID']."'".$isSelected.">".$row['cn']."</option>\n";
}
$tablecode .= "</select>";
return ($tablecode);
}
}
它们看起来是一样的,但是它们是不同的类,使用相同的sql数据库和相同的数据库连接器代码。
this is the coding error I have been getting
我去找老师,朋友和导师。我也用谷歌搜索过
1条答案
按热度按时间ix0qys7i1#
尝试使用PDO。https://www.php.net/manual/en/book.pdo.php。
如果此代码不起作用,则可能是数据库连接错误。