varun7952 Posted October 11, 2012 Share Posted October 11, 2012 i m tryin to fetch random images from database on external page it fetch id user id name but not image and i only want to fetch images(thumb) please guys help me here is my code <?php $connect= mysql_connect('localhost','root',' '); if($connect) { mysql_select_db ('wall_paper',$connect); $query= ("SELECT * FROM wallpapers ORDER BY Rand() LIMIT 5"); $result= mysql_query($query); echo "<table border='1'>"; while ($row=mysql_fetch_array($result, MYSQL_NUM)){ echo "<tr><td>$row[0] </td><td>$row[1]</td><td>$row[2]</td></tr>"; } echo "</table>"; } else{ echo "cant connet to the database"; } ?> i attached image of my database from where i m fetching data Quote Link to comment Share on other sites More sharing options...
premiso Posted October 11, 2012 Share Posted October 11, 2012 Where is the image being stored? On a file? How do you know the path / location to the image? That code you have there, even the database image, does not hint to any such information. We will need to know that to assist you. Quote Link to comment Share on other sites More sharing options...
varun7952 Posted October 14, 2012 Author Share Posted October 14, 2012 picture stored in hash Quote Link to comment Share on other sites More sharing options...
premiso Posted October 15, 2012 Share Posted October 15, 2012 picture stored in hash Can you post the code where you actually insert the picture into the database, because afaik, you cannot store a "picture" in a hash. You could store the picture's file name as a hash... Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 15, 2012 Share Posted October 15, 2012 Storing the "picture" or the name as a hash would be pretty useless, since a hash is one way. So... Quote Link to comment Share on other sites More sharing options...
Christian F. Posted October 15, 2012 Share Posted October 15, 2012 Actually, hashing the image's data and then renaming the file is a pretty good idea; No filename collisions, and you can test quite easily if you have the picture already (or not). Of course, it's pointless unless you rename the file. Quote Link to comment Share on other sites More sharing options...
DavidAM Posted October 15, 2012 Share Posted October 15, 2012 Actually, hashing the image's data and then renaming the file is a pretty good idea; No filename collisions, and you can test quite easily if you have the picture already (or not). Of course, it's pointless unless you rename the file. Hashes are not guaranteed to be unique, so there is still the potential for a name collision. And since there may be collisions with different data, you cannot be sure that a duplicate hash means you have received a duplicate image. All in all, hashing the image data and using it as the filename is not such a good idea. Also, consider that a user may add (or remove) tag data to (or from) an image, and it would produce a different hash even though the visual image is the same. Hashes are designed to "prove" that the data has been changed. You could store the hash of a (image) file in the database; then, before displaying the image, run a hash on the file and compare the two hashes. If they are different, then someone changed the file; if they are the same, then the file has probably not been changed. Since hashes are not guaranteed to be unique, it is conceivable that the file could be changed in such a way as to cause the hash to be the same. Using a salt helps prevent someone from purposefully making such a change; since without the salt they don't know what hash value they are working toward. And the odds of it happening accidentally are very slim. Quote Link to comment Share on other sites More sharing options...
varun7952 Posted November 5, 2012 Author Share Posted November 5, 2012 thx to all guys and grls for thr help @david said i think i should follow him not to store picture in hash i will try something different thx u guys Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.