[PHP-DB] Re: session variable in select query showing picture from database

2009-02-12 Thread David Robley
Mika Jaaksi wrote: I'm trying to show picture from database. Everything works until I add variable into where part of the query. It works with plain number. example ...WHERE id=11... ...picture is shown on the page. Here's the code that retrieves the picture. show_pic.php ?php

[PHP-DB] Re: session variable in select query showing picture from database

2009-02-12 Thread Mika Jaaksi
Thanks for the quick responce... to Valentin Nedkov: I have session_start() on another page. Session start gets band_id as a value when user logs in. I've tried to echo session variable on show_pic page and it works. And I belive that I can't set default value for band_id because the picture I

[PHP-DB] Re: session variable in select query showing picture from database

2009-02-12 Thread Mika Jaaksi
Still fighting with it... So, these work: $query=SELECT * FROM pic_upload; $query=SELECT * FROM pic_upload WHERE band_id=11; picture is shown on the other page but when adding variable into query it doesn't show the picture on the other page $query=SELECT * FROM pic_upload WHERE

[PHP-DB] Re: session variable in select query showing picture from database

2009-02-12 Thread Mika Jaaksi
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

[PHP-DB] Re: session variable in select query showing picture from database

2009-02-12 Thread Mika Jaaksi
Okay, I added it and got this SELECT * FROM pic_upload WHERE band_id=11 Seems to me that it's the way i should be. For some mystical reason it still doesn't work...

RE: [PHP-DB] Re: session variable in select query showing picture from database

2009-02-12 Thread Fortuno, Adam
: session variable in select query showing picture from database Still fighting with it... So, these work: $query=SELECT * FROM pic_upload; $query=SELECT * FROM pic_upload WHERE band_id=11; picture is shown on the other page but when adding variable into query it doesn't show the picture on the other

[PHP-DB] Re: session variable in select query showing picture from database

2009-02-12 Thread Mika Jaaksi
Sorry, but this didn't work either $query=SELECT * FROM pic_upload WHERE band_id='${band_id}'; Thanks to everybody who has tried to help...

Re: [PHP-DB] Re: session variable in select query showing picture from database

2009-02-12 Thread danaketh
Don't see session_start() in your script. If you work with SESSION, you must have it on the first lines of the file (before any output and work with $_SESSION so it's good to put it on the first lines). And it must be in every file which works with them (except for included files). It should

[PHP-DB] Re: session variable in select query showing picture from database

2009-02-12 Thread Mika Jaaksi
$band_id = 11; $query=SELECT * FROM pic_upload WHERE band_id=$band_id; print_r($_SESSION); gives this: Array ( [session_var] = 11 ) and picture is shown on the page And about the session start: I have session start on the index2.php page when user has logged in. Page that should show the

[PHP-DB] Re: session variable in select query showing picture from database

2009-02-12 Thread Mika Jaaksi
*Answer to Rick: in your code below it looks like you're simply hard-coding your $band_id value (as 11) -- so of course it's going to work. *Yes, I did that because one of you helpers asked me to try that. I'll try to be clearer on whom I'm answering to...

[PHP-DB] Re: session variable in select query showing picture from database

2009-02-12 Thread Mika Jaaksi
With these: $band_id = $_SESSION['session_var']; echo band_id: . $band_id; $query=SELECT * FROM pic_upload WHERE band_id=$band_id; echo query: . $query; I get these: band_id: 11 query: SELECT * FROM pic_upload WHERE band_id=11 SQL injections: Are these what I should use? $db = new

Re: [PHP-DB] Re: session variable in select query showing picture from database

2009-02-12 Thread chris smith
On Fri, Feb 13, 2009 at 6:01 PM, Mika Jaaksi mika.jaa...@gmail.com wrote: With these: $band_id = $_SESSION['session_var']; echo band_id: . $band_id; $query=SELECT * FROM pic_upload WHERE band_id=$band_id; echo query: . $query; I get these: band_id: 11 query: SELECT * FROM pic_upload