Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

View Uploaded File??

Status
Not open for further replies.

zishan876

Programmer
Mar 19, 2007
61
US
Hi I have completed the upload file part of my website... Now I want to let users view the file they uploaded...
So I created a table and Wanted to view the file through img src tag.. but it is not working...
In the database, I add the file path but in my directory it is added as a jpeg??
Here is my code
Code:
<table border="1" cellspacing="2" cellpadding="2">
<tr>
<th><font face="Arial, Helvetica, sans-serif">School</font></th>
<th><font face="Arial, Helvetica, sans-serif">Site</font></th>
<th><font face="Arial, Helvetica, sans-serif">Address</font></th>
<th><font face="Arial, Helvetica, sans-serif">Address 2</font></th>
<th><font face="Arial, Helvetica, sans-serif">City</font></th>
<th><font face="Arial, Helvetica, sans-serif">State</font></th>
<th><font face="Arial, Helvetica, sans-serif">Phone</font></th>
<th><font face="Arial, Helvetica, sans-serif">Email</font></th>
<th><font face="Arial, Helvetica, sans-serif">Photo</font></th>
</tr>
<?php
//set your connection string
$username="whhhhh;
$password="whhhh";
$database="whhhh";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

//place your query statement into a variable string
$query="Select * from school ";

//for execution $result variable will place the string for querying purposes
$result=mysql_query($query);

//how many rows does the above query bring up
$num=mysql_numrows($result);

//close if there is no recordsets
mysql_close();


echo "<b><center>MMA Schools</center></b><br><br>";

//loop through the recordset

$i=0;
while ($i < $num) {

//assign each field to a variable

//$variable=mysql_result($result,$i,"fieldname");

$school = mysql_result($result,$i,"name");
$site = mysql_result($result,$i,"site");
$address= mysql_result($result,$i,"street");
$street2= mysql_result($result,$i,"street2");
$city = mysql_result($result,$i,"city");
$state= mysql_result($result,$i,"state");
$phone= mysql_result($result,$i,"phone");
$email= mysql_result($result,$i,"email");
$photo= mysql_result($result,$i,"photo");
?>
<tr>
<td><font face="Arial, Helvetica, sans-serif"><? echo $school; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><a href="[URL unfurl="true"]http://<?[/URL] echo $site; ?>" class="lightwindow"><? echo $site; ?></a></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo $address; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo $street2; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo $city; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo $state; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo $phone; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo $email; ?></font></td>
<td><img src="mmaxtra.com/<? echo $photo; ?>"></td><==NOT WORKING

</tr>


<?
$i++;
}

echo "</table>";
 
First what does your image tag end up looking like once its produced onto the web page.

Use view Source to see what is being produced?

I'm, not sure what you mean by this:
In the database, I add the file path but in my directory it is added as a jpeg??




----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
ok.. First thanks for helping me out...
Here is the file when it uploads into my directory:
Second, when I stated I added the file path into the directory...
When an user, adds there info, I take the path of the picture that has been uploaded and place it in the database, thinking that I can do a img src tag to get the photo...
So for example for this:


The path that went into my DB for photo field was
sphotos/muaythai23.jpg ...

If you like you can check out

I have a list there but no photo... it is the img src tag that I am having an issue with..
Cool
Thanks for helping me out...
 
This is what your image src ends up looking like:
Code:
<img src="/public_html/mmaxtra.com/sphotos/muaythai23.jpg">


I'm pretty sure you don't have a folder named nmaxtra.com inside your public_html folder in your site.

First thing to do is to figure out where the /public_html/ part is coming form.

I can't see it anywhere in your code.

You can try just making the source of your img something like:
<img src=" echo $photo ?>">






----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top