Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

MySQL question

  • 30-01-2000 4:15pm
    #1
    Closed Accounts Posts: 202 ✭✭


    Anybody know how to allow BLOBs that contain single quotes into a record? At the moment I have to strip them from the incoming text and I can't see any reliable way of putting them back

    Here's the problem:

    $text = "It's a way of life";

    $sth = $dbh->prepare("INSERT INTO table(text) VALUES('$text')");

    The single quote inside the string is interpolated. I was thinking maybe I could replace them with something else before I put them into the record and then swapping back when I take it out of the record, but what could I use? Would it be safe to use some weird ASCII character for this?

    Thanks


    Doh! I could just wrap the SQL statement in single quotes couldn't I?


    [This message has been edited by Karla (edited 30-01-2000).]


Comments

  • Registered Users, Registered Users 2 Posts: 2,494 ✭✭✭kayos


    ok first thing first why are you tring to put a string in a image field. Well here it goes any who. If you want to put single quotes into a string field you would use syntax as follows.
    Insert
    TableName
    (
    FieldName
    )
    Values
    (
    'It''s a way of life'
    )
    Note that It's has two single quotes and not a double quote. Well thats how you do a string field in SQL Server so it should work for you. If you need any more help just give us a shout.

    Kayos

    [This message has been edited by kayos (edited 31-01-2000).]


  • Closed Accounts Posts: 202 ✭✭Karla


    Huh? I wasn't putting it into an image field.

    Anyway I found a way around it, since I'm using MySQL on the Web I just had to replace every apostrophe with the escape character & # 039 ; like this:

    $text =~ s/'/\&\#039\;/g;

    Works just fine smile.gif

    Thanks anyway


  • Registered Users, Registered Users 2 Posts: 2,494 ✭✭✭kayos


    A blob field is an image field in SQL 6.5


  • Closed Accounts Posts: 202 ✭✭Karla


    That's MS SQL Server right?

    I'm pretty sure that a BLOB is for loads of text too yeah?



  • Registered Users, Registered Users 2 Posts: 2,494 ✭✭✭kayos


    Blob stands for Binary Large Object and should not really be used for just straight text. The way you would use a blob to store large amounts of text would to be write the text out to a file and then insert that file into a blob field. Then to get the text back onpen a file of binary access and write the blob to it and then opne and read the file. If you want I'll mail you some sample code (VB6).

    KaYoS

    DIM KaYoS As DataObject


  • Advertisement
  • Closed Accounts Posts: 202 ✭✭Karla


    Yeah, cheers that would be great

    My email addy is bracken@webmongers.org

    Binary Large Object eh? Oops smile.gif

    So would a TEXT datatype be ok for a message board-type comment? If not what would you suggest? Or should I use separate files like you said.

    I'm kinda finding my way along in the dark here so forgive me smile.gif

    Thanks a lot



Advertisement