Re: [PHP] How to call image from mySql to php file

2007-02-23 Thread Richard Lynch
On Wed, February 21, 2007 8:26 am, 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'";
>
> $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.

Your goal is to get valid HTML to be output, that does what you want.

Use "View Source" in your browser to see what you have.

Does this look like valid HTML:
 images/logos/some_logo.jpg 
that does what you want?

How could you change your source to make it look like valid HTML that
does what you want?

Hint:  You need an IMG tag somewhere.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] How to call image from mySql to php file

2007-02-21 Thread Németh Zoltán
2007. 02. 21, szerda keltezéssel 06.26-kor Chris Carter ezt írta:
> 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'";

be aware of sql injection. check the data before putting it into a
query.
and also, I do not recommend using $_REQUEST, it is better to use
$_POST/$_GET instead

> 
> $result=mysql_query($query);
> $num=mysql_numrows($result);

this is

mysql_num_rows($result);

correctly

> 
> mysql_close();
> $logos=mysql_result($result,$i,"logos");

I recommend mysql_fetch_row or mysql_fetch_assoc instead
http://hu.php.net/manual/en/function.mysql-fetch-row.php
http://hu.php.net/manual/en/function.mysql-fetch-assoc.php

if you have several rows in the result then do something like

while ($row = mysql_fetch_row($result)) {
// here you have a filename in $row[0]
// do whatever you want to do with it, for example:
echo "";
}

hope that helps
Zoltán Németh

> 
> 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.
> 
> -- 
> 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



[PHP] How to call image from mySql to php file

2007-02-21 Thread 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.

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