I tried $query = "SELECT * FROM pic_upload WHERE band_id = '".$_SESSION['session_var']."' "; didn't work. And I've tried to echo session variable and it has right data in it. I've also tried band_id=$band_id band_id='$band_id' band_id="$band_id" band_id='{$band_id}' band_id="{$band_id}" Session variable is 11 in this case and the picture is shown when I use ...WHERE band_id=11... but not when I use variable. What could be the difference between plain number (11) and variable (I've echoed it so I know it's 11 too)?