Re: How to call image from mySql to php file

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

 



Hello,
       Firstly, your image table field should be BLOB field then you create 
a image file (for example image.php). in this file, if your application is 
more secure, you can control the session variables. You get key column of 
your BLOB table (for example id, studentnumber and so on) with session 
variables, GET variables or any way. I always get this column with SESSION 
variables because it is more secure. After this, for get variables you can 
call the image to your main application from image.php file with  like the 
following HTML1 code. for session variables you can call the image to your 
main application from image.php file with  like the following HTML2 code.

HTML 1 Code - for get variables
<img src="image.php?id=1923">

HTML 2 Code - for session variables
<img src="image.php">

image.php
<?php
session_start();
if (!session_is_registered ('username'))
{
     include('hack.inc.php');
     exit;
}

$id=$_SESSION["id"]; //for session variables

$hostname="host.haydartuna.net";
$username="username";
$password="xxxxx";
$database="myapplication";
@ $db=mssql_pconnect ($hostname, $username,$password)
or die ('Error');
mssql_select_db($database);
$sql="select picture from table where id='$id' ";
$result=mssql_query($sql);
$row=mssql_fetch_assoc($result);
echo($row['resim']);
?>


-- 
Haydar TUNA
Republic Of Turkey - Ministry of National Education
Education Technology Department Ankara / TURKEY
Web: http://www.haydartuna.net

"Chris Carter" <chandan9sharma@xxxxxxxxx>, haber iletisinde sunlari 
yazdi:9081704.post@xxxxxxxxxxxxxxxxxx
>
> I have a field in database called "logos" which has one value
> "images/logos/some_logo.jpg"
>
> In my php I am trying to call it in my php file as image. With this code.
>
> $sno = $_REQUEST['sno'];
>
> $query="SELECT logos FROM table WHERE sno = '$sno'";
>
> $result=mysql_query($query);
> $num=mysql_numrows($result);
>
> mysql_close();
> $logos=mysql_result($result,$i,"logos");
>
> echo "
> <div>
> <p> $logos </p>
> </div>";
>
> ?></div>
>
> But getting errors. What is the way to call image in php file from the
> database. I know that this is a very basic question but first time for me. 
> I
> ignored this in the begining but now its right infront of me.
>
> Please advice.
>
> -- 
> View this message in context: 
> http://www.nabble.com/How-to-call-image-from-mySql-to-php-file-tf3267012.html#a9081704
> Sent from the PHP - General mailing list archive at Nabble.com. 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux