How to call image from mySql to php file

How to call image from mySql to php file

am 21.02.2007 12:26:44 von Chris Carter

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 "


$logos


";

?>

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.

Chris
--
View this message in context: http://www.nabble.com/How-to-call-image-from-mySql-to-php-fi le-tf3266161.html#a9079259
Sent from the Php - Database mailing list archive at Nabble.com.

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

RE: How to call image from mySql to php file

am 21.02.2007 16:39:41 von Bastien Koert

Simple, just add the image tag around it

$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 "



";

Bastien
>From: Chris Carter
>To: php-db@lists.php.net
>Subject: [PHP-DB] How to call image from mySql to php file
>Date: Wed, 21 Feb 2007 03:26:44 -0800 (PST)
>
>
>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 "
>

>

$logos


>
";
>
>?>
>
>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.
>
>Chris
>--
>View this message in context:
>http://www.nabble.com/How-to-call-image-from-mySql-to-php-f ile-tf3266161.html#a9079259
>Sent from the Php - Database mailing list archive at Nabble.com.
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>

____________________________________________________________ _____
Your Space. Your Friends. Your Stories. Share your world with Windows Live
Spaces. http://spaces.live.com/?mkt=en-ca

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

Re: How to call image from mySql to php file

am 22.02.2007 00:43:36 von dmagick

Chris Carter wrote:
> 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'";

Please please please read http://www.phpsec.org/

particularly

http://phpsec.org/projects/guide/3.html#3.2

--
Postgresql & php tutorials
http://www.designmagick.com/

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

Re: How to call image from mySql to php file

am 22.02.2007 07:21:40 von Haydar TUNA

Hello,
I think you embed picture path to a table. This is very easy solution
to using picture. in your code you close the your mysql connection and after
this you call the mysql_result. if you close the connection before call the
result, it happen a problem. You cannot call result set after close the
connection. You should close the connection all of process.:))
if you call the picture in HTML with img tag. in your code if you
change the echo line like this echo ", you will see
the picture:)



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


"Chris Carter" wrote in message
news:9079259.post@talk.nabble.com...
>
> 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 "
>


>

$logos


>
";
>
> ?>
>
> 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.
>
> Chris
> --
> View this message in context:
> http://www.nabble.com/How-to-call-image-from-mySql-to-php-fi le-tf3266161.html#a9079259
> Sent from the Php - Database mailing list archive at Nabble.com.

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