Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
问题是“stdClass 类的对象无法转换为 int”
这是代码:
$user = mysql_fetch_object(mysql_query("SELECT * FROM `user` WHERE username='$user_name'")); if($user) == 0){
我怎么解决这个问题?
您正在从数据库中获取对象,而不是字符串或 int,因此需要对类中的字段进行访问,然后例如检查可以通过以下方式完成字段:
if ($user->user_id === null ) or if ($user->{'user.id'} == null ) if there are problems with `user.id`