gpt4 book ai didi

php - fatal error : Call to undefined method User->get_fullname()

转载 作者:行者123 更新时间:2023-11-29 12:28:01 26 4
gpt4 key购买 nike

我在从数据库获取数据时遇到问题。这是我的功能:

        public function get_fullname($uid) 
{
$result = mysql_query("SELECT name FROM users WHERE uid = $uid");
var_dump(mysql_result($result));
if(mysql_result($result)>0){
//$user_data = mysql_fetch_array($result);
echo $user_data['name'];
}
else{
print_r('chuj');
}
}

这是我的函数调用:

$uid = $_SESSION['uid'];

$user = new User();
$register = $user->get_fullname($uid);

我的代码有什么问题吗?

文件 Functions.php 中的完整类:

    include_once 'config.php';
class User
{
//Połączenie z bazą danych
public function __construct()
{
$db = new DB_Class();
}
//Rejestracja
public function register_user($name, $username, $password, $email)
{
$password = md5($password);
$sql = mysql_query("SELECT uid from users WHERE username = '$username' or email = '$email'");
$no_rows = mysql_num_rows($sql);
if ($no_rows == 0)
{
$result = mysql_query("INSERT INTO users(username, password, name, email) values ('$username', '$password','$name','$email')") or die(mysql_error());
return $result;
}
else
{
return FALSE;
}
}
//Logowanie
public function check_login($emailusername, $password)
{
$password = md5($password);
$result = mysql_query("SELECT uid from users WHERE email = '$emailusername' or username='$emailusername' and password = '$password'");
$user_data = mysql_fetch_array($result);
$no_rows = mysql_num_rows($result);
if ($no_rows == 1)
{
$_SESSION['login'] = true;
$_SESSION['uid'] = $user_data['uid'];
var_dump($_SESSION);
return TRUE;
}
else
{
return FALSE;
}
}
//Pobieranie imienia
public function get_fullname($uid)
{
$result = mysql_query("SELECT * FROM users WHERE uid ='".$uid."'");
$user_data = mysql_fetch_array($result);
$no_rows = mysql_num_rows($result);
if($no_rows>0){
$user_data = mysql_fetch_array($result);
//echo $user_data['name'];
return $user_data['name'];
}
else{
print_r('chuj');
return FALSE;
}
}
//Sesja
public function get_session()
{
return $_SESSION['login'];
}
//Wylogowanie
public function user_logout()
{
$_SESSION['login'] = FALSE;
session_destroy();
}

}

?> fatal error :调用未定义的方法 User->get_fullname()

最佳答案

Rizier123 的评论是正确的,但不是问题的原因。

我尝试重现该错误,但失败了。这意味着您可能在某处使用旧版本。如果您使用FTP等,您确定在添加该功能后上传了User类吗?

此外,请确保最新的 User 类包含在您使用它的文件中。

关于php - fatal error : Call to undefined method User->get_fullname(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28010704/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com