473,778 Members | 1,911 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieving and Formatting a Blob Object

I've created a MySQL database to store a large amount of text. Since
the text data type in MySQL is limited to 255 characters, I added a
BLOB column. I created an PHP input screen to enter the large text.
It seems to work. But, I cannot verify the entry, because the
standard select SQL does not display the contents. I want to
retrieve the contents from the database and display on a web page.
The retrieval seems to occur. But, I can't display the results,
because I must not be done the proper conversion from BLOB to ordinary
text.

Can somebody help me resolve this problem?

Here is the insert code I'm using.

$newtext = addslashes($blo b);
@ $db = mysql_connect(' localhost', '<database>', '<password>');
if (!$db)
{
echo "Error: Could not connect to database. Please try again
later.";
exit;
}
mysql_select_db ("<database> ");
$query = "insert into blog values ('$newtext')";
$result = mysql_query($qu ery);

if ($result)
{
echo mysql_affected_ rows()." text item inserted into
database.";
}

Here is the retrieval code I'm using.

$query = "select blogtext from blog";
$result = mysql_query($qu ery);
while ($row = mysql_fetch_arr ay($result)) {
$blog = $row['blogtext'];
$wraptext = wordwrap($blog, 80, "\n", 1);
echo $wraptext;
}

It displays nothing on my page.

Thanks in advance.
Jul 17 '05 #1
5 2680
I noticed that Message-ID:
<e4************ **************@ posting.google. com> from Bob Kaku
contained the following:
$query = "insert into blog values ('$newtext')";


$query = "insert into blog (blogtext) values ('$newtext')";

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2
Geoff Berrow <bl******@ckdog .co.uk> wrote in message news:<55******* *************** **********@4ax. com>...
I noticed that Message-ID:
<e4************ **************@ posting.google. com> from Bob Kaku
contained the following:
$query = "insert into blog values ('$newtext')";


$query = "insert into blog (blogtext) values ('$newtext')";

Geoff,

I tried your suggestion. The insert seems to work. But, I still have
the problem of not being able to display the contents of this BLOB
column. Thanks anyway. Perhaps, someone else has a solution.

Bob Kaku
bo*****@yahoo.c om
Jul 17 '05 #3
I noticed that Message-ID:
<e4************ **************@ posting.google. com> from Bob Kaku
contained the following:
Geoff,

I tried your suggestion. The insert seems to work. But, I still have
the problem of not being able to display the contents of this BLOB
column. Thanks anyway. Perhaps, someone else has a solution.

'Seems' to? Can't you check using phpMyAdmin or something?
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #4
On 18 Mar 2004 19:47:35 -0800, bo*****@yahoo.c om (Bob Kaku) wrote:
I've created a MySQL database to store a large amount of text. Since
the text data type in MySQL is limited to 255 characters, I added a
BLOB column.


Actually, TEXT can store 64k. BLOB isn't for text, it's for binary data
(although the only real difference AFAIK is that using the binary types turns
off case-insensitivity).

VARCHAR can only store 255.

--
Andy Hassall <an**@andyh.co. uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk > / <http://www.andyhsoftwa re.co.uk/space>
Jul 17 '05 #5
Andy Hassall <an**@andyh.co. uk> wrote in message news:<8j******* *************** **********@4ax. com>...
On 18 Mar 2004 19:47:35 -0800, bo*****@yahoo.c om (Bob Kaku) wrote:
I've created a MySQL database to store a large amount of text. Since
the text data type in MySQL is limited to 255 characters, I added a
BLOB column.


Actually, TEXT can store 64k. BLOB isn't for text, it's for binary data
(although the only real difference AFAIK is that using the binary types turns
off case-insensitivity).

VARCHAR can only store 255.


Yes, thanks for the answer. I actually found this out myself by doing
a little more research. I now know I can use TEXT, MEDIUMTEXT or
LONGTEXT. But, TEXT seems fine for most uses. I need to examine the
online manual a little deeper before posting a message

Bob Kaku
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1165
by: jty202 | last post by:
Hi, I like to know how I can retrieve an image and set it to an Image object. I seem to can't find anything on the net that can help me on this. Thanks
0
3141
by: Paul Kennedy | last post by:
I have a situation where I am utilizing code from MSDN to insert XLS files into a Microsoft Access Table in a column of Ole Object using VBA and DAO. That code also provides me with a method to extract the XLS files later. This works wonderfully. The Article is 103257, ACC: Reading, Storing, & Writing Binary Large Objects (BLOBs) http://msdn.microsoft.com/library/default.asp?url=/library/en-us/oledb/htm/oledbaccessing_blob_data.asp I...
3
3013
by: Dennis | last post by:
How can I save then retrieve an image from an access Database using VB.Net? -- Dennis in Houston
0
1262
by: Utilisateur1 | last post by:
Hello, I've a problem retrieving a blob column from oracle. I'm using oledbadapter to fill a dataset like that oledataadap.fill(ds,"query"); I'm also using ColumnMapping to have more friendly column headers in dataset. The Fill method send an error with no explaznation except this "the type is not managed". Has somebody ideas about to solve that ?
2
9001
by: pmz | last post by:
Dear Group, I'm connecting in C# with remote (BSD) MySQL server with ODBC Driver, and I'm trying to find the best sollution in such problem: As I've read on MySQL manual, they have suggested table design including the BLOB-Fieldtype size in UInt64, where they've stored, while inserting, the size of inserted BLOB data. But in the matter of fact, I'm interested if it's necessary to include in table this integer field? Is there any way...
11
3935
by: Peter Afonin | last post by:
Hello, I have Word documents stored in the Oracle database in the BLOB field that I need to retrieve. I've found the way of doing it: While dr.Read sName = dr("TE_PM_ATTACH_NAME") bLob = dr.GetOracleLob(1)
9
8002
by: matt | last post by:
hello, im doing my first ASP.NET app that inserts & retrieves files from Oracle (no need for a discussion on *that*!). i learned first-hand of the somewhat awkward technique for inserting binary data into an Oracle BLOB column via ADO.NET. since my files are larger than 33k, it seemed had to use this technique: http://support.microsoft.com/default.aspx?scid=kb;en-us;322796
0
1903
by: coony | last post by:
Hi everyone, I got an annoying thing going on. I've got an MSSQL db which is filled with different data, used by another program (T-Plan). I should read some table to import in another DB. The DB I have to read, contains als BLOB files. In Excel I created a connection string, can read all fields & values as shown in the DB, but I can't manage to convert the Blobs to Strings (which is the data in the BLOBs). I tried all the next, but...
1
3080
by: sana krishna | last post by:
Pls Help me-------------- I use ASP(C#.NET) and oracle. When i retrive image from database .it display error message... System.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.Byte'. my code in the show button is.pls anybody help me ,how to retrive and display the image protected void btnshow_Click(object sender, EventArgs e) { DataTable dt = ds.Tables; MemoryStream stream = new...
0
9629
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9470
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
10127
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...
1
10069
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9923
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
7475
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
6723
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3627
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2865
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.