注意:类stdClass的对象无法转换为int

注意:类stdClass的对象无法转换为int,class,object,int,stdclass,Class,Object,Int,Stdclass,问题是“类stdClass的对象无法转换为int” 这是代码: $user = mysql_fetch_object(mysql_query("SELECT * FROM `user` WHERE username='$user_name'")); if($user) == 0){ 如何解决此问题?您正在从数据库中获取对象,而不是字符串或int 因此,您需要在类中访问metchod字段,然后可以通过以下方式进行字段检查(例如检查): if ($user->user_id === null

问题是“类stdClass的对象无法转换为int”

这是代码:

$user = mysql_fetch_object(mysql_query("SELECT * FROM `user` WHERE username='$user_name'"));
if($user) == 0){

如何解决此问题?

您正在从数据库中获取对象,而不是字符串或int 因此,您需要在类中访问metchod字段,然后可以通过以下方式进行字段检查(例如检查):

if ($user->user_id === null )

or

if ($user->{'user.id'} == null )

if there are problems with `user.id`