tango4cash Posted March 30, 2010 Share Posted March 30, 2010 Ok so I am deveopling a site for one of my clients, and I had to use some php I am not familiar with to do what he wants. Basically, all I am doing is displaying data from a mysql table on an html table on a website. However, one of the feilds is a BLOB and I am uploading pdfs to this feild. I need to be able to display them as a little pdf icon so they are downloadable. Currently, when I upload the pdf to the table, it is displayed all funky with tons of weirds characters. Here is one of the pages I am talking about. http://gator452.hostgator.com/~teiweb/?page_id=58 Where I currently have "test1,test2" etc is the feild where I need it to be downloadable. I need it like this page here, where they have "specs" as a downloadable file on each one. http://www.sinwan.com/sinwan_web/sho...ial_Plastic_AC Here is the code I am currently using -----------------Here is the Code---------------------------- <?PHP # Param 1 : MySQL Host Name # Param 2 : MySQL Username # Param 3 : MySQL Password # Param 4 : MySQL Database # Param 5 : SQL Statement (SELECT) show_table("localhost","MYUSERNAME","MYPASS","MYDATABASE","SELECT * FROM MYTABLENAME"); function show_table($hostName,$userName,$passWord,$dataBase,$sqlQuery) { # Connect to MySQL $conn=mysql_connect($hostName,$userName,$passWord); # Select Database mysql_select_db($dataBase,$conn); # Validate SQL Statement $array=explode(" ORDER",$sqlQuery); $sqlQuery=$array[0]; if(!strstr($sqlQuery,"SELECT")) die("Invalid Query : SQL statement should be a SELECT statement."); # ORDER records by requested column if($_GET['order']) $sqlQuery=$sqlQuery." ORDER BY ".$_GET['order']; # Execute SQL query $result=mysql_query($sqlQuery) or die("Invalid Query : ".mysql_error()); $row=mysql_fetch_array($result); # Check whether NULL records found if(!mysql_num_rows($result)) die("No records found."); echo "<table border=1><tr>"; # Make the row for table column names while (list($key, $value) = each($row)) { $i++; if(!($i%2)) echo "<td><b><a href='?order=$key'>$key</a></td>"; } echo "</tr>"; $result=mysql_query($sqlQuery); // Make rows for records while($rec=mysql_fetch_array($result)) { echo "<tr>"; for($i=0;$i<count($rec);$i++) { if($rec[$i]) echo "<td>$rec[$i]</td>"; } echo "</tr>"; } echo "</table>"; } ?> --------------------------------------------- Link to comment https://forums.phpfreaks.com/topic/197048-file-upload-problem/ Share on other sites More sharing options...
AdRock Posted March 30, 2010 Share Posted March 30, 2010 why don't you just put a link to the file in the database. That's what i do with an image gallery Link to comment https://forums.phpfreaks.com/topic/197048-file-upload-problem/#findComment-1034415 Share on other sites More sharing options...
neogemima Posted March 30, 2010 Share Posted March 30, 2010 Yes, I have tried the field type BLOB before and they are a hug headache. Instead, just have an uploads folder on your database similar to your "images" folder where the pdf files are actually sent. Then, store the name of that file in your table so you can recall only that part when the user wants to download it. You'll need to take special considerations to make sure no file names are ever duplicated, so renaming them upon upload is a must, perhaps use a timestamp or something added to the end of them to make them unique. Good luck! Link to comment https://forums.phpfreaks.com/topic/197048-file-upload-problem/#findComment-1034419 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.