473,799 Members | 3,209 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Displaying data from blob fields

27 New Member
Hi,
I've been dabbling with mysql php and xml...
I have managed to learn how to upload xml file into mysql datbase and download the file from mysql database to display the content on the file. However the
What i would like to know is how do i manipulate the php codes to display the content on the file in a proper form?...
So far i have done this:
Expand|Select|Wrap|Line Numbers
  1. <?
  2. if(isset($_GET['id']))
  3. {
  4.     include 'config.php';
  5.     include 'opendb.php';
  6.  
  7.     $id      = $_GET['id'];
  8.     $query   = "SELECT name, type, size, content FROM upload WHERE id = '$id'";
  9.     $result  = mysql_query($query) or die('Error, query failed');
  10.     //list($name, $type, $size, $content) = mysql_fetch_array($result);
  11.     $list= mysql_fetch_array($result);
  12.     while ($list = mysql_fetch_array($result)) { 
  13.             $field1=$content["field1"];
  14.             $field2=$content["field2"];
  15.                   $field2=$content["field3"];
  16.         $field2=$content["field4"];
  17.         $field2=$content["field5"];
  18.         $field2=$content["field6"];
  19.  
  20.             // display recordset data
  21.             echo "<table>";
  22.             echo "<tr>";
  23.             echo "<td>Field1 Name =</td>";
  24.             echo "<td>$field1</td>";
  25.             echo "</tr><tr>";
  26.             echo "<td>Field2 Name =</td>";
  27.             echo "<td>$field2</td>";
  28.             echo "</tr>";
  29.             echo "<td>Field3 Name =</td>";
  30.             echo "<td>$field3</td>";
  31.             echo "</tr><tr>";
  32.             echo "<td>Field4Name =</td>";
  33.             echo "<td>$field4</td>";
  34.             echo "</tr><tr>";
  35.             echo "<td>Field5 Name =</td>";
  36.             echo "<td>$field5</td>";
  37.             echo "</tr><tr>";
  38.             echo "<td>Field6 Name =</td>";
  39.             echo "<td>$field6</td>";
  40.             echo "</tr><tr>";
  41.             echo "</table>";
  42.         }
  43.  
  44.  
  45.     //header("Content-Disposition: attachment; filename=$name");
  46.     //header("Content-length: $size");
  47.     //header("Content-type: $type");
  48. //    echo $content;
  49.  
  50. //    include 'closedb.php';    
  51.     exit;
  52. }
  53.  
  54. ?>
  55. <html>
  56. <head>
  57. <title>Download File From MySQL</title>
  58. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  59. </head>
  60.  
  61. <body>
  62. <?
  63. include 'config.php';
  64. include 'opendb.php';
  65.  
  66. $query  = "SELECT id, name FROM upload";
  67. $result = mysql_query($query) or die('Error, query failed');
  68. if(mysql_num_rows($result) == 0)
  69. {
  70.     echo "Database is empty <br>";
  71. else
  72. {
  73.     while(list($id, $name) = mysql_fetch_array($result))
  74.     {
  75. ?>
  76.     <a href="download.php?id=<?=$id;?>"><?=$name;?></a> <br>
  77. <?        
  78.     }
  79. }
  80. //include 'closedb.php';
  81. ?>
  82. </body>
  83. </html>
  84.  

but when i execute this ...I neither get an error or a warning.A blank page is displayed.
Please do help.....
Thanks
Aug 8 '07 #1
1 2724
Atli
5,058 Recognized Expert Expert
Hi.

I have a few comments on your code. They may even solve your problem, who knows.

First, PHP code should be encapsulated in <?php .. ?> blocks
<? ..?> may also work on some server, but I would recommend against it.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.   echo "This is how it should be";
  3. ?>
  4.  
  5. <?
  6.   echo "Some servers can be configured to use this, but why take the chance?";
  7. ?>
  8.  
Second, I do not know if <?= $myVar ?> acctually works, but this is how it should be done:
Expand|Select|Wrap|Line Numbers
  1. <?php echo $myVar; ?>
Third; Use good variable names, like say $NameFiled and $PasswordField and not $Field1, $Field2. Makes debuggin much easier.

You may not have noticed, but you use $Field2 for 4 out of 5 fields your database returns to you.

Lastly, I see you put the $id in your SQL query inside quote marks. If it is, as I hope it is, a numeric value, it should not be encapsulated in quotemarks.

Hope this helps
Aug 8 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
5800
by: euang | last post by:
Hi, I have been using access 2000 for two years on WINDOWS NT to display dynamic aweb page using ASP My ISP has now changed to Windows 2003, and I am having major problems displaying information from MEMO fields within the Access 2000 database. I have not had any problems before displaying MEMO fields on NT and have tried various tips to resolve this issue but no luck so far. I was wondering if anyone had come accross a similar...
1
4198
by: ij | last post by:
Hi, I'm trying to submit an image object, along with some other text fields to another web server from within an ASP page but am stuck on getting the image to be submitted with the form. In a bit more detail: 1. When this particular page is executed, I want the server to pull an image from a db (stored as a BLOB) along with a few other text fields. This part is easy and I have no problems with it.
0
623
by: AJ Shankar | last post by:
Hi, In the C API, is there any way to execute a query, store all the results, and somehow find the maximum realized width for each of the fields before fetching each row? Otherwise there is no way to efficiently retrieve string data. The best you can do is either allocate a static buffer of 64K (max size for a blob) or some smaller buffer that may not actually be able to contain all the data.
3
5021
by: Dave Crypto | last post by:
Hi There, SUMMARY: I need to know what the actual maximum date limit possible on a row of a MYSQL database. MORE DETAILS: For example, does a MYSQL database only allow 4032 bytes of data to be
2
1787
by: zhaounknown | last post by:
I have a field set to Image data type, and store a long string(possible other objects)into it with size 5663, and returned with 5663+28 bytes. These strings wil be deserialized after retrieving. However failde because the bytes seems to include some extra bytes with \0 and 0x01 and have 28 more bytes ahead of the original string. How could I deal with it? Just remove the first 28 bytes? It this method formal? I had thought the returned...
3
4728
by: hamvil79 | last post by:
I'm implementig a java web application using MySQL as database. The main function of the application is basically to redistribuite documents. Those documents (PDF, DOC with an average size around 2Mb) are stored in BLOB column. The amount of documents for the first year should not exceed 5/6 Giga, but I cannot make prevision for the next years. Those documents are mainly just accessed (update and delete are not so
5
16135
by: Mark | last post by:
I have a VB 6 program that I have saved an audio file to using DAO and the appendchunk as is shown at http://support.microsoft.com/kb/103257/EN-US/. ; I have it working fine in that app (it saves to an access database and I can save the data back to a file using getchunk and everything works correctly). The issue is that I am now trying to access the database in VB.NET 2003 through an OleDBDataAdapter (Jet 4.0 connection) and can't get it...
3
5829
by: CD | last post by:
An application is logging faxes sent in SQL2000 image column type. I have found code on the net but what it is doing is prompting to save to local which is fine for single page image. Not good for multiple page faxes. I have not been able to locate an example to load in the browser or how to handle multiple image in the one column. 1) Ideally it would be nice to display back in the browser since some may be multiple images. I am not...
7
10164
by: greywire | last post by:
So I need to load lots of data into my database. So I discover LOAD DATA INFILE. Great! This little gem loads my CSV in blazing times (compared to parsing the file and doing INSERT for each row). Its still slow on large files, but just barely acceptable. Only one problem. It truncates fields to 256 characters, even on a text field.
0
9546
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10490
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10260
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10030
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5590
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4146
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.