Eggzorcist Posted August 26, 2012 Share Posted August 26, 2012 Hey everyone. For some reason, one of my function does not display what it is supposed to and even outside the function after it has been called any echo's after it won't be echoe'd. Here is my function: function friendsList($id){ $query = $dbh->prepare("SELECT users.id, users.fb_id, users.fb_pic, users.fn FROM users INNER JOIN friendlist ON users.fb_id = friendlist.friend2 WHERE friendlist.friend1 = ? AND friendlist.status = 1"); $query->bindValue(1, $id); $query->execute(); $friendNum = $query->rowCount(); $friendList = $query->fetchAll(PDO::FETCH_ASSOC); $output = ""; foreach($friendList as $row){ $output .= "<img src ='". $row['users.fb_pic']. "alt = '". $row['users.fn'] ."' /> "; $output .= $row['users.fn']. "</br>"; } return $output; } Could it be my MAMP server? I don't get any PHP errors and have looked numerous times throughout this function to find nothing out of the ordinary. Thanks for the headsup Quote Link to comment https://forums.phpfreaks.com/topic/267602-function-bugging-out/ Share on other sites More sharing options...
.josh Posted August 26, 2012 Share Posted August 26, 2012 $dbh is not within scope of your function. You need to pass it to your function or declare it as a global variable (assuming it is globally scoped) Quote Link to comment https://forums.phpfreaks.com/topic/267602-function-bugging-out/#findComment-1372612 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.