shan2batman Posted July 11, 2016 Share Posted July 11, 2016 hi, i'm trying to verify whether someone has like a post or not here and it is not giving the expected output but a empty array.Any help would be great. Thanks in advance. //fetch user_id from update table in db and inject it to the feed query. $totalUpdates=$project->totalUpdates1($id,$load); $total_sess_count=$project->totalupdatescount($id); foreach ($totalUpdates as $j=>$row1) { $updateid=$row1['update_id']; $account_name=$row1['account_name']; $u_id=$row1['user_id_u']; $author=$row1['author']; $post_date=$row1['time']; $title= stripslashes($row1['title']); $data= stripslashes($row1['update_body']); $data1= hashtags($data); //$data1= taggingsys($data0); $pic=$project->viewByUname($author); $uid=$pic['user_id']; $datemade = strftime("%B %d", strtotime($post_date)); $avatar=$pic['avatar']; if ($avatar!=""){ $feed_pic='user/'.$uid.'/'.$avatar; } else { $feed_pic='img/avatardefault.png'; } //logic to check if someone has liked or not. $liked_check="select voted_id from voted_u where user_id_v=:sess_id and vote_4_update_id=:updateid "; $stmt_liked=$conn->prepare($liked_check); $stmt_liked->bindValue(":sess_id", $_SESSION['id']); $stmt_liked->bindValue(":updateid",$updateid); $like_check=$stmt_liked->fetchAll(); if ($like_check>0) { $uname_liked=TRUE; } Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted July 11, 2016 Share Posted July 11, 2016 Without knowing what is stored to define whether a like has been attached and what exactly you should be getting back we won't know if there is an issue with the query, syntactically the php looks ok but it's always a worthy debugging step to fling in a var_dump($stmt_liked->errorInfo()) just after the query to see if it's doing what it should be. Quote Link to comment Share on other sites More sharing options...
Solution Barand Posted July 11, 2016 Solution Share Posted July 11, 2016 You haven't executed the prepared statement Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted July 11, 2016 Share Posted July 11, 2016 Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted July 11, 2016 Share Posted July 11, 2016 this would be another good reason to ascend to a higher plane of programming existence and reuse proven, tested, general purpose code. so that each time you do the same thing, you don't have to beat on the keyboard typing out bespoke code and queries, then find and fix all the typo's and missing or wrong statements. reusing proven, tested, and general purpose code will let you concentrate on the program flow and the goal you are actually trying to accomplish, rather than on the tedious details of each step you take along the way. Quote Link to comment 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.