Re: How to call image from mySql to php file
| From: | Colin Guthrie | Date: | Thu, 22 Feb 2007 09:34:11 +0000 |
| Subject: | Re: How to call image from mySql to php file | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-249215@lists.php.net to get a copy of this message | ||
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