Jump to content
shan2batman

not able fetch results from tables

Recommended Posts

Remove that if($total_row>0) stuff. Not only is it using the wrong variable, at best it's completely unnecessary.

Share this post


Link to post
Share on other sites
1 hour ago, shan2batman said:

if($row1['user_id_pm']==$_SESSION['id'])

Another useless bit of code. Your where clause contains ...

 

1 hour ago, shan2batman said:

and pm_notifications.user_id_pm=:sess

so you either get no results or all user_id_pm values are $_SESSION['id']

Share this post


Link to post
Share on other sites

@Barand i changed the query to something below but still the problem still it is not fetching results

 

$query="select private_message.receiver,pm_notifications.message_id,pm_notifications.user_id_pm,user.user_id,user.avatar from pm_notifications"
        . " inner join private_message"
        . " on private_message.os_id=pm_notifications.os_id_pm"
        . " inner join user"
        . " on user.user_id=pm_notifications.user_id_pm"
        . " where private_message.receiver=:sess_id"
        . " and private_message.sender=:f_uname and pm_notifications.status=:status and pm_notifications.receiver=:f_uname"
       . " order by pm_notifications.pm_notification_id  desc" ;
//var_dump($query);
$status='not_seen';


$stmt_pm_f=$conn->prepare($query);
$stmt_pm_f->bindValue(":f_uname", $friend_username);
//$stmt_pm_f->bindValue(":f_uname1", $friend_username);
//$stmt_pm_f->bindValue(":sess",$_SESSION['id']);
$stmt_pm_f->bindValue(":sess_id",$_SESSION['uname']);
$stmt_pm_f->bindValue(":status",$status);
$stmt_pm_f->execute();
$results_pm_f=$stmt_pm_f->fetchAll();
$total_row_f=$stmt_pm_f->rowCount();
var_dump($results_pm_f);
var_dump($stmt_pm_f->rowCount());

 

Edited by shan2batman

Share this post


Link to post
Share on other sites

You cannot reuse a placeholder in a query. You still need f_uname1.

Did you change any other code?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.