Jump to content


Photo

blob


  • Please log in to reply
4 replies to this topic

#1 mbvo

mbvo
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 05 October 2006 - 08:47 PM

How do I read from a blob field?  And is it correct that I would use a text area to write to a blob?  if not what do I write using a text area?

#2 mbvo

mbvo
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 05 October 2006 - 09:11 PM

my code is:

$result = mysql_query("SELECT * FROM calendar where num = ".$_GET['num']);
$row = mysql_fetch_array($result);
.
.
.
echo "<BR><BR>Description:<BR>'".$row['description']."'";

I'm sure it's getting the correct row, because it's displaying other data from it, but it won't display anything from the description filed(which is a blob data type).

#3 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 05 October 2006 - 09:19 PM

there's a simple rule I personally follow myself regarding PHP/MySQL. If you don't know what something is, you either don't need it or should look it up in the manual if you're curious. (I don't mean that in a dismissive way either  :) ).

There are so many different field types in MySQL that cater for all sorts. Me personally, i've only probably used about 6 or 7 different ones ever (less if you dont consider the variants - SMALLINT, INT, BIGINT, etc). Some of the others I will probably never have a use for.

Getting data from a blob field is no different really from any other field in terms of getting data from it. A normal SELECT will suffice. Whilst I can't honestly say I know exactly the full/proper use for the blob field, i've always used it to store binary data. Anything that is generally entered via a <form> can be put in the basic types - VARCHAR (or CHAR), INT (or its smaller/larger variants), TEXT, etc. a textarea would be suited to putting data into a TEXT field, not a BLOB.

hope that makes sense
cheers
Mark
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#4 mbvo

mbvo
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 05 October 2006 - 09:27 PM

perfectly, and after posting I've been looking around more on google and playing with my code, and i got it to display all but the first line using a varchar field, and changing it to nl2br($row['description']).  But now my question is why is it now displaying the first line?

#5 mbvo

mbvo
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 05 October 2006 - 09:53 PM

perfectly, and after posting I've been looking around more on google and playing with my code, and i got it to display all but the first line using a varchar field, and changing it to nl2br($row['description']).  But now my question is why is it now displaying the first line?


I feel stupid now, I just looked at the source code for the page and the browser is interperting it wrong was my problem.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users