Re: How to call image from mySql to php file

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

 



Hi,

Some points already given by others just reiterating:

Chris Carter wrote:

>  $sno = $_REQUEST['sno'];

$_REQUEST is dodgy - you don't know what makes it up (cookies, post, get
etc.), only use it when it when you are sure.

> $query="SELECT logos FROM table WHERE sno = '$sno'";

NEVER do this. VERY dangerous. Always use mysql_real_escape or similar
delimiting functions on input data.

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

You can't close it yet.....

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

.... as you need it here!!

Also $i is not initialised, I presume you mean to use $num? Even so, if
there is 1 row, you will be passing in 1 and this would not return any
results! If you want the last row returned you would have to pass in
($num - 1).

HOwever if $i is indicative of a for loop, you are better using the
fetch associative arrays functions alreayd mentioned and a while loop.

> echo "
> <div>
> <p> $logos </p>
> </div>";
> 
> ?></div>


You'd presumable by better with: echo "<img src=\"$logos\" />" or similar :)

HTH

Col

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