ByteArray objects cannot be converted to strings

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default ByteArray objects cannot be converted to strings

    We're migrating our application server from ColdFusion 5.1 to CF MX 7, and
    running into an issue with a specific web page. Our news stories are posted
    via a CF admin interface and they post to a MySQL database. The page in
    question is here:

    [url]http://newdraco.hood.edu/news/index.cfm?pid=_story_details.htm&featureID=1164&ty[/url]
    pe=0

    If you load this page you'll get an error stating:


    ByteArray objects cannot be converted to strings.




    Now what's interesting is that the page posts the title and date of the news
    release so those database fields (title, dateFormat) are working. However the
    error occurs in the "story" database field. This field is specified in our
    database as "BLOB." I get the same error message if I enable the BLOB in my
    CFAdmin. So it appears that the BLOB is the problem.

    What's even more interesting is if I change the BLOB to "LONGTEXT" in the
    database. Then if I enable both BLOB and CLOB in the CFAdmin, the stories post
    without a problem. Some characters display funny, but for the most part the
    entire story runs without error.

    So, my question is whether any other CF users have encountered this issue??
    If you have do you have a workaround to suggest. I suppose it could be fixed
    by tweaking my coldfusion code on the actual page in question but I'm not sure
    on this. Here's the code for the page generating the error:

    <cfquery name="getFeatureDetails" dbtype="ODBC" datasource="newsInfo">

    SELECT * FROM features WHERE featureID = #url.featureID#

    </cfquery>

    <p><span class="pageTitleBlue">News @ Hood: </span><span
    class="commSubTitle"><cfif url.type IS 0>
    News Releases
    <cfelseif url.type IS 1>Campus News</cfif></span></p>

    <cfoutput query="getFeatureDetails">
    <!--- <TABLE WIDTH="100%" BORDER=0 CELLPADDING=6 CELLSPACING=0>
    <TR BGCOLOR=##edf0f3><TD><b>Story Details</b></TD></TR>
    </TABLE> --->
    <p><span class="pressReleaseTitle">#title#</span><br><span
    class="pressReleaseDate">#DateFormat(dateAdded)#</span>
    <p>#ParagraphFormat(story)#
    </CFOUTPUT>


    Thanks in advance!!

    -Trevor

    --
    Trevor James
    Web Site Manager
    Hood College
    Office of Marketing and Communications
    Frederick, MD 21701

    Phone: (301) 696-3846
    Email: [email]james@hood.edu[/email]

    TrevJames Guest

  2. Similar Questions and Discussions

    1. ByteArray objects cannot be converted to strings??
      I am using dreamweaverMX and ColdfusionMX to create a site that will display photos along with text info describing the photo. I have an Access DB...
    2. Byte Array objects cannot be converted to strings Error-- SQLExpress DB
      Hi I recently upgraded one server to be using SQL Express 2005 Now when I try to output the value of a ROWGUID its giving me this Error Occurred...
    3. #26265 [NEW]: zend_parse_parameters() doesn't coerce overloaded objects into strings
      From: adam at trachtenberg dot com Operating system: * PHP version: 5CVS-2003-11-15 (dev) PHP Bug Type: Zend Engine 2 problem...
    4. #25122 [NEW]: Control over typecasting objects to strings
      From: a at b dot c dot de Operating system: Any PHP version: 5.0.0b1 (beta1) PHP Bug Type: Feature/Change Request Bug...
    5. #8325 [Opn->Bgs]: numeric strings used as keys are converted to longs
      ID: 8325 Updated by: helly@php.net Reported By: cynic at mail dot cz -Status: Open +Status: Bogus...
  3. #2

    Default Re: ByteArray objects cannot be converted to strings

    I think your problem is with how you're outputting the BLOB data. Don't think
    you can just do a..

    <cfoutput>#SomeBLOBValue#</cfoutput>

    Try using 'toString' function....

    <cfoutput>#toString(SomeBLOBValue)#</cfoutput>


    BSterner Guest

  4. #3

    Default Re: ByteArray objects cannot be converted to strings

    That worked! I converted the code to this:
    #ToString(story)#

    The stories are posting now:

    [url]http://newdraco.hood.edu/news/index.cfm?pid=_story_details.htm&featureID=1151&ty[/url]
    pe=2

    However, I'm noticing that some apostrophes are not converting correctly.
    You'll notice small question mark icons within the body of the story content.
    Any suggestions on how to make these convert?

    Thanks!

    -Trevor


    TrevJames Guest

  5. #4

    Default Re: ByteArray objects cannot be converted to strings

    encoding issue. what encoding did you use to add the data? what encoding on your cf pages?

    might try toString(SomeBLOBValue,"your encoding")
    PaulH Guest

  6. #5

    Default Re: ByteArray objects cannot be converted to strings

    You can use the replace or replacelist functions to convert any non-printable
    characters to printable ones.

    eg) #Replace(ToString(story), "`", "'");#

    You'll need to find out what the characters being stored in the database are
    in order to convert.

    btw, that address you posted is not working for me. I tried a dns lookup on
    'newdraco.hood.edu' and it found nothing. Is it the same address as
    [url]http://hood.edu/news/index.cfm?pid=_story_details.htm&featureID=1151&ty pe=2?[/url]

    Can you attach the actual raw data beind returned from the db.

    BSterner Guest

  7. #6

    Default Re: ByteArray objects cannot be converted to strings

    it's more an issue of encoding than printable vs non-printable. it's generally
    a bad idea to replace chars like that. in some instances, say email w/some kind
    of corporate compliance rules in place, it might even be illegal. whatever
    folks put into a database they should be able to get back, not what the
    developer thinks they meant.


    PaulH Guest

  8. #7

    Default Re: ByteArray objects cannot be converted to strings

    Paul,

    Do you mean the character encoding in the meta info of our site's pages. That's:

    charset=iso-8859-1

    -Trevor
    TrevJames Guest

  9. #8

    Default Re: ByteArray objects cannot be converted to strings

    I agree, I'd like to resolve this within our site's code before dealing with
    the database. I inherited this application and the text content field was
    added to the database as a BLOB specified datatype. I do know that we're using
    MySQL version 3.23 and I don't believe that version supports the TEXT datatype.
    I'd like to store the data as TEXT but this would require an upgrade to MySQL
    4.1 correct?

    I believe the character encoding we're using is:
    ISO 8859-1

    -Trevor

    TrevJames Guest

  10. #9

    Default Re: ByteArray objects cannot be converted to strings

    no, cf ignores the meta header stuff. what encoding did you use in your editor, etc.?
    PaulH Guest

  11. #10

    Default Re: ByteArray objects cannot be converted to strings

    I'm taking copy out of a word document. I saved it as plain text and encoded
    it as UTF-8 (while saving in word). Then I copied the plain text and pasted
    into our CF admin application that we use to enter news items. It's still
    displaying apostrophes as boxes (in IE) and diamonds with ? (in Firefox).

    I use Dreamweaver as my editor as far as coding HTML and CF. We are running
    CF 5.1, but I'm testing out our CF MX 7 server currently. The stories display
    without issue on our CF 5.1 server but the character issues are happening on
    the new server.

    Help!

    -Trevor

    TrevJames Guest

  12. #11

    Default Re: ByteArray objects cannot be converted to strings

    well cf5 doesn't know unicode from hole in the ground. making it work in cf5
    will bite you in the nether regions later on when you upgrade to cf7.

    smart quotes, etc. from word are either unicode or a windows codepage
    (probably windows western european) which is a superset of iso-8859-1. if you
    need to start this w/cf5 i'd try to replace those chars w/ico-8859-1
    equivalents & stay away from utf-8 until you move to mx.


    PaulH Guest

  13. #12

    Default Re: ByteArray objects cannot be converted to strings

    I guess I'm getting confused! It is working in CF 5 and has been. It's going
    to CF MX which is the problem. I've been copying and pasting content from word
    files directly into our news admin section on CF 5 without issue. But now,
    when I view the same articles on the CF MX server, I'm getting the character
    issues. The issue seems to be moving the ico-8859-1 characters over to CF MX??

    -Trevor

    TrevJames Guest

  14. #13

    Default Re: ByteArray objects cannot be converted to strings

    I just tried adding the following code to my index page (in the news section)
    on the new CF MX server:

    <cfcontent type="text/html; charset=iso-8859-1">

    Now the news stories are displaying without character issue. The only problem
    that remains is the paragraphs are not correct in the story - but this can be
    taken care of by adding <p> tags when posting the story. So it looks like this
    solves it for now. Basically just specifying not to use UTF on the CF MX
    (since that's the default, correct?) - but to use ISO-8859-1 instead.

    -Trevor

    TrevJames Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139