Strategy to enter data into MySQL

This thread is based off a problem I had earlier this week…

I’m looking for a more practical strategy to enter articles into my MySQL database.

Currently all of my articles are .php files, and I tried cutting and pasting the body of each into the web form provided by phpMyAdmin, but it is complaining about single quotes/apostrophes?! And this is a real problem, because the body of my articles is Copy + HTML markup, so each is littered with HTML references to images and hyperlinks and thus tons of single and double quotes?!

What I am currently doing, is pasting the article body into a field called “body” and then using PHP to echo $body;

Here is a snippet of what the body of an article might look like…


<img src="../images/SmilingGirl.jpg" width="200"
	alt="Picture: Smiling Girl.  Credit: Lisa Miller."
	title="Picture: Smiling Girl.  Credit: Lisa Miller." />
<p>Last Saturday, students from the local college...</p>

What is the best way to handle data like this so that I can easily get it into MySQL and not have to spend a lifetime fixing things because phpMyAdmin and/or MySQL doesn’t like the original Text and HTML?!

Thanks,

Debbie

Import them via a PHP script. Use mysql_real_escape_string to make your data safe for insertion.

Read about mysql_real_escape_string in the PHP manual.

Ideally create your own data entry form and use prepared statements with variable binding. That would be the best long term solution. Entering data via phpMyAdmin is less then ideal for several reasons, one of which your experiencing.

What other reasons make using phpMyAdmin less than ideal?

So if I enter data into MySQL using a web form that I build myself, then I won’t have any issues with copying and pasting my original HTML/Text (including single and double quotes)?

Debbie