chris11 Posted May 29, 2009 Share Posted May 29, 2009 What ive done is upload a fie to my server and categorized it in mysql with an id name. Im trying to fetch that file by calling for the id name "download.php?id=" and print or echo it a link with the file name not id number. This is what im working with and am getting an Parse error: syntax error, unexpected '<' in /home... on line blue <?php $query = "SELECT id, name FROM uploads"; $result = mysql_query($query) or die('Error, query failed'); if(mysql_num_rows($result) == 0) { echo "Database is empty <br>"; } else { while(list($id, $name) = mysql_fetch_array($result)) [color=blue]<a href="download.php?id=<?php echo urlencode($id);?>"><?php echo urlencode($name);?></a> <br>[/color] } ?> So yeah. Ive been messing around with it and I magically fix one error only to refresh to another . Any insight would be awesome. Thanks Link to comment https://forums.phpfreaks.com/topic/160208-download-by-file-id/ Share on other sites More sharing options...
waynew Posted May 29, 2009 Share Posted May 29, 2009 This should work: <?php $query = "SELECT id, name FROM uploads"; $result = mysql_query($query) or die('Error, query failed'); if(mysql_num_rows($result) == 0){ echo "Database is empty <br>"; } else{ while(list($id, $name) = mysql_fetch_array($result)){ echo '<a href="download.php?id='.$id.'">'.$name.'</a><br />'; } } ?> Link to comment https://forums.phpfreaks.com/topic/160208-download-by-file-id/#findComment-845331 Share on other sites More sharing options...
chris11 Posted May 29, 2009 Author Share Posted May 29, 2009 thanks. that fixed everything Link to comment https://forums.phpfreaks.com/topic/160208-download-by-file-id/#findComment-845350 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.