•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 374,004 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,741 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser:
Views: 1482 | Replies: 38 | Solved
![]() |
hello i am trying to display an image from a database which has just been uploaded by the user. when they go onto the next page the image should be displayed here.
I have been able to get it to display the path for the image that haas been stored using this code
but when i try to use the img tag it displays nothing.
the path has been stored in the mysql table images_broad in broad1 and the path is stored in a variable called $newname2.
when the image is meant to be displayed the source code has then img tag as empty. I no it is going to be something silly stopping it from working but it would be nice if someone could show me why this is not working.
I have been able to get it to display the path for the image that haas been stored using this code
$sql= "SELECT * FROM images_broad";
$query = mysql_query($sql);
$result = mysql_fetch_array($query) or die (mysql_error());
echo $result ['broad1'];but when i try to use the img tag it displays nothing.
the path has been stored in the mysql table images_broad in broad1 and the path is stored in a variable called $newname2.
when the image is meant to be displayed the source code has then img tag as empty. I no it is going to be something silly stopping it from working but it would be nice if someone could show me why this is not working.
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,041
Reputation:
Rep Power: 8
Solved Threads: 227
You have stored something like:
http://www.server.com/filelocation.png
in the database?
If so when fetching the values back from the db have you tried doing something like:
This should do the job! Any other problems let me know.
Regards,
Alex.
http://www.server.com/filelocation.png
in the database?
If so when fetching the values back from the db have you tried doing something like:
php Syntax (Toggle Plain Text)
$query = "SELECT * FROM images_broad"; $result=mysql_query($query); while($row=mysql_fetch_array($result, MYSQL_ASSOC)){ echo '<img src="'.$row['broad1'].'"/>'; }
This should do the job! Any other problems let me know.
Regards,
Alex.
Last edited by peter_budo : Apr 3rd, 2008 at 10:52 am. Reason: Keep It Organized - please use [code] tags
If you find my post useful please add to my reputation!! Thanks!
ajtrichards web solutions
http://www.ajtrichards.co.uk
ajtrichards web solutions
http://www.ajtrichards.co.uk
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,041
Reputation:
Rep Power: 8
Solved Threads: 227
Do you have these files on a server so that we can check the output ? Because, I don't understand what exactly is the problem..
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
if you go to www.acmert.co.uk/mercury this is what i have been working on. not all of it is set up yet but if you login (i will give you the password in a private message) and then click on the layout button then go to broadsheet upload some images and then go to the preview page you will see what i mean about the image being repeated.
also you will see the next problem i am having. instead of it placing the both images on the page it replaces the first one.
also you will see the next problem i am having. instead of it placing the both images on the page it replaces the first one.
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,041
Reputation:
Rep Power: 8
Solved Threads: 227
I checked it and this is what I find.
http://acmeart.co.uk/mercury/image/t...1207128520.jpg all the images have the same path. That is why the image is being repeated. While fetching the path from the table, check if it returns the right path. Then, there are only 2 input type='file'. So whenever you upload an image and then another (using the same upload file tag) it gets replaced.
http://acmeart.co.uk/mercury/image/t...1207128520.jpg all the images have the same path. That is why the image is being repeated. While fetching the path from the table, check if it returns the right path. Then, there are only 2 input type='file'. So whenever you upload an image and then another (using the same upload file tag) it gets replaced.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb MySQL Marketplace
Similar Threads
Other Threads in the MySQL Forum
- Previous Thread: creating tables
- Next Thread: Queries and sub-queries



Linear Mode