我收到了这些错误:
Warning: Illegal string offset 'approved' in C:... on line 137
Warning: Illegal string offset 'approved' in C:... on line 147
但是,我检查print_r()我可以调用哪些值并得到它:
Array (
[0] => 3
[id] => 3
[1] => 3
[user_fk] => 3
[2] => > Jailbot 2.0
[title] => > Jailbot 2.0
[3] => 1
[approved] => 1
)
那为什么不让我打电话批准?
PHP:
$avatarQuery = "SELECT * FROM avatars WHERE user_fk = {$id} LIMIT 1";
$avatarSet = mysql_query($avatarQuery, $connection);
confirm_query($avatarSet);
$count = mysql_num_rows($avatarSet);
if($count == 1){
$avatar = mysql_fetch_array($avatarSet);
$avatar = $avatar['picture'];
$avatarApproved = $avatar['approved'];
}else{
$avatar = "images/noImage.png";
}
$titleQuery = "SELECT * FROM titles WHERE user_fk = {$id} LIMIT 1";
$titleSet = mysql_query($titleQuery, $connection);
confirm_query($titleSet);
$title = mysql_fetch_array($titleSet);
$title = $title['title'];
$titleApproved = $title['approved'];
答案 0 :(得分:2)
$avatar = $avatar['picture'];
$avatarApproved = $avatar['approved'];
第一行用$ avatar ['picture']的值覆盖$ avatar,所以当你执行第二行时,$ avatar不再是一个数组;并且您在后续查询结果中使用$ title执行相同操作