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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reply to post 'How do you retrieve links in MYSQL

Status
Not open for further replies.

kjspear

Programmer
Feb 13, 2002
173
US
Hello,

I created a simple database. All this database does is store links of files which were uploaded from the user. A sample of the link is stated below;

d:/mysql/data/uploads/image011.jpg

Now, how do I retrieve this link so that it can be read and display the image on screen (ie. php or html file)?

I was trying the use the code below but the image does nt come up;

<?php
$db=mysql_connect(&quot;lanycomputer&quot;,&quot;someuser&quot;,&quot;&quot;)
or die(&quot;Could not connect : &quot; . mysql_error());
print &quot;Connected successfully&quot;;
print &quot;<br>&quot;;
print &quot;<center><h2><b>My Picture</b></h2></center>&quot;;
mysql_pconnect();
mysql_select_db(&quot;myimages&quot;) or die(&quot;Could not select database&quot;);
$query = &quot;SELECT * FROM myimage&quot;;
$result = mysql_query($query) or die(&quot;Query failed : &quot; . mysql_error());
/* Printing results in HTML */
print &quot;<br>&quot;;
print &quot;<table width=75% border=1>\n&quot;;
print &quot;<td width=14%><b>UserID</b></td>&quot;;
print &quot;</tr>&quot;;
print &quot;</table>&quot;;

while ($row= mysql_fetch_array($result))

{
print &quot;<table width=75% border=1>\n&quot;;
print &quot;<td width=8%>&quot;;

I THOUGHT READFILE() WOULD WORK

readfile(&quot;c:/mysql/data/mylogin/image2.jpg&quot;);
print $row[&quot;imagefilepath&quot;];
print &quot;<img src='$row[imagefilepath]'>&quot;;
print &quot;</td>&quot;;


I tried using the three commands listed above to see if I could get a display. But I was not successful.
Using readfile just makes the browser hang.

Any assistance would be appreciated.

Thanks,
KJ


 
O.K., folks, I got it on my own. I had it right. I discovered that for some reason when I upload the image file, the name of the files didn't match the database.

Thanks
KJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top