Re: session variable in select query showing picture from database

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 want get is depended on who has logged in.

to Jason Pruim:

when I look at what show_pic shows, it's whole lot of this:
ÿØÿà�JFIF��N�N��ÿÀ��âŠ�ÿÛ�„�.....

When I used plain number or WHERE band_id='{$band_id}'  those weird
markings(above) were identical. (They were different when not using these '{
}' )
And the code works with plain number so we must be closer to the truth now..

to David Robley:

band_id is set to session variable when user logs in...


-Mika Jaaksi



2009/2/12 Mika Jaaksi <mika.jaaksi@xxxxxxxxx>

> 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
> function db_connect($host='********', $user='********',
> $password='********', $db='********')
> {
> mysql_connect($host, $user, $password) or die('I cannot connect to db: ' .
> mysql_error());
> mysql_select_db($db);
> }
> db_connect();
> $band_id = $_SESSION['session_var'];
> $query="SELECT * FROM pic_upload WHERE band_id=$band_id";
> $result=mysql_query($query);
> while($row = mysql_fetch_array($result))
> {
> $bytes = $row['pic_content'];
> }
> header("Content-type: image/jpeg");
> print $bytes;
>
>
> exit ();
> mysql_close();
> ?>
>
>
> other page that shows the picture
>
> <?php
> echo "<img width='400px' src='./show_pic.php' />";
> ?>
>
> Any help would be appreciated...

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux