unplugged_web Posted February 19, 2008 Share Posted February 19, 2008 I've been sent some files that I need to upload to a database. All of the files are .ldf but I don't know how to add them to an existing database and then view them.I have MySQL Administrator, but I've never used it before and am nervous as it says you should use any important data until you are sure of what you're doing. Link to comment Share on other sites More sharing options...
justsomeguy Posted February 19, 2008 Share Posted February 19, 2008 I don't know what MySQL Administrator is, but if you want to store a file in a database you need to use a blob column. If you're using PHP you can use file_get_contents to get the data that you store in the database. Reading the file back out means sending a header to set the content type and filename before you send the data out. I've never used it before and am nervous as it says you should use any important data until you are sure of what you're doing.That doesn't seem to stop most people on this forum.. Link to comment Share on other sites More sharing options...
unplugged_web Posted February 19, 2008 Author Share Posted February 19, 2008 I don't know what MySQL Administrator is, but if you want to store a file in a database you need to use a blob column. If you're using PHP you can use file_get_contents to get the data that you store in the database. Reading the file back out means sending a header to set the content type and filename before you send the data out.That doesn't seem to stop most people on this forum..Sorry to sound so stupid, but does that mean I can use file_get_contents to read the data from the ldf files and then if I want use something else to transform it into a text file? Link to comment Share on other sites More sharing options...
justsomeguy Posted February 19, 2008 Share Posted February 19, 2008 file_get_contents gets the contents of the file (oddly enough). So the return value of that function will be the data in the file. If it is an ASCII file then it will be an ASCII string, if it is a binary file then it will be a binary string. I don't know what LDF data is, and I don't know what the algorithm is to convert LDF data to text if it's not already in that format, so I can't help you there. Link to comment Share on other sites More sharing options...
unplugged_web Posted February 20, 2008 Author Share Posted February 20, 2008 file_get_contents gets the contents of the file (oddly enough). So the return value of that function will be the data in the file. If it is an ASCII file then it will be an ASCII string, if it is a binary file then it will be a binary string. I don't know what LDF data is, and I don't know what the algorithm is to convert LDF data to text if it's not already in that format, so I can't help you there.Thanks Link to comment Share on other sites More sharing options...
unplugged_web Posted February 21, 2008 Author Share Posted February 21, 2008 I used file_get_contents to read the file, but just ended up with loads of funny symbols.The code I used was <?phpecho file_get_contents ("pointOne_Dev_log.LDF");?> You can see what happened here Link to comment Share on other sites More sharing options...
justsomeguy Posted February 21, 2008 Share Posted February 21, 2008 This is what I see: Windows Registry Editor Version 5.00[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]"pointOne"="c:\\program files\\pointone\\pointone.exe""Nomad"="c:\\program files\\nomad\\nomad.exe" That is what goes in a .reg file to be added to the Windows registry, that specific code creates 2 entries of programs to run when you start Windows. Link to comment Share on other sites More sharing options...
unplugged_web Posted February 22, 2008 Author Share Posted February 22, 2008 Sorry I was testing another file format and forgot to revert it. If you look now you'll get the funny symbols.Thanks Link to comment Share on other sites More sharing options...
justsomeguy Posted February 25, 2008 Share Posted February 25, 2008 Yes, that is the binary content of the file being shown as ASCII text. You can save that in a database or whatever, it's not helpful to print it out just because binary data is not human-readable, it's meant for the computer. If you want to download the file you'll need to send a different content type header, right now the server is claiming that page is text/html. Link to comment Share on other sites More sharing options...
unplugged_web Posted February 26, 2008 Author Share Posted February 26, 2008 Yes, that is the binary content of the file being shown as ASCII text. You can save that in a database or whatever, it's not helpful to print it out just because binary data is not human-readable, it's meant for the computer. If you want to download the file you'll need to send a different content type header, right now the server is claiming that page is text/html.Thanks for that - I guess I need to import it into a database Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.