Pasting article into phpMyAdmin

Is there a safe way to paste an article into phpMySQL?

I just got an error from phpMyAdmin because apparently what I pasted contained the worl Don’t and the single apostrophe maybe threw things off?!

(Over the last few years I have become so confused about the whole debate of whether you should escape and strip characters and what not.)

Can someone enlighten me here?

Thanks,

Debbie

P.S. Most of the fields in my “Article” table are pretty standard, however the “body” field could likely have just about any character.

definitely sounds like the apostrophe problem

do you have to use phpmyadmin? any chance you could use another front end tool?

i paste raw html including text with aprostrophes into heidisql all the time, and it takes care of escaping the apostrophes for you

So how do you handle that problem and other special/problematic characters?

do you have to use phpmyadmin? any chance you could use another front end tool?

What other choices would I have?

(Originally I wrote the articles in OO Write, pasted them in NetBeans, and then added the HTML. But now that I am converting all of my physical articles to MySQL records, I need a way to get thinsg into my database. More so, moving forward I’ll still need a way to get data in MySQL.)

i paste raw html including text with aprostrophes into heidisql all the time, and it takes care of escaping the apostrophes for you

I am using “MediumText”.

Is this a database issue? Or a data-type issue? Or do I need to clean things up in PHP?

Debbie

P.S. I don’t do Windows!!

when you provide a value to be inserted into a string datatype (varchar, text, mediumtext, whatever), the string value needs to be enclosed in apostrophes

each apostrophe that is embedded in your string value must be escaped

the standard sql way of doing it is to code two consecutive apostrophes for each occurrence

INSERT 
  INTO person ( ... surname ... )
    VALUES ( ... 'O''Toole' ... )

you can try doing this with a text editor, but i wouldn’t be surprised if phpmyadmin actually had an option for it, although i can’t really help you with that as i don’t use it myself

Can I use a different delimiter?

each apostrophe that is embedded in your string value must be escaped

the standard sql way of doing it is to code two consecutive apostrophes for each occurrence

INSERT 
  INTO person ( ... surname ... )
    VALUES ( ... 'O''Toole' ... )

you can try doing this with a text editor, but i wouldn’t be surprised if phpmyadmin actually had an option for it, although i can’t really help you with that as i don’t use it myself

What if I use a backslash (\) ??

And if I do that, then how do I get rid of the escaping character when I display the article in my web page using PHP?!

Debbie

yes, you can use a different string delimiter in mysql – doublequotes

yes, you can use a backslash to escape embedded apostrophes

no, the escape character will not show up when you retrieve the data

how much of this have you tried to test?

testing is dead simple and takes much less time than asking for help

CREATE TABLE test_strings
( id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT
, foo VARCHAR(99)
);
INSERT INTO test_strings ( foo ) VALUES
( 'Howard' ),( 'Fine' ),( 'O''Toole' ),( 'O\\'Toole' )
, ( "That's what she said" )
, ( 'That''s what she said' )
;
SELECT * FROM test_strings;

[QUOTE=r937;4934334no, the escape character will not show up when you retrieve the data

how much of this have you tried to test?[/QUOTE]

YES, my backslash (\) is showing up in my php page…

Debbie

Are you posting the body directly into phpmyadmin or built a backend fform?

As I said before, I composed the articles in OO Write, pasted them into NetBeans, marked up the text, and wha-la… working php articles.

So now I am copying and pasting the marked up articles frome ach respective php file into phpMyAdmin so they are in my database.

I tried manually adding a backslash before each apostrophe, and it seems to work, BUT that is a alot of work AND I now have backslashes showing in my web page?!

Debbie

try escaping with a single quote instead of backslash