apostrophe problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dru_nasty
Forum Commoner
Posts: 81
Joined: Sat Sep 10, 2005 10:26 am

apostrophe problem

Post by dru_nasty »

I've seen fixes when using mysql through a command line but I'm not sure how to tweak my php code to work.

I've got a form, when filled out with and apostrophe like don't, will not pass into my db. I don't want to have to add backslashes each time I enter an apostrophe, so how can I fix this?

Here's the sql statement.

Code: Select all

$sql ="INSERT INTO `testTable` values ('', '$_POST[headline]','$_POST[content]')";

if (mysql_query($sql,$conn)){
echo "records added!";
}else{
echo "something went wrong";
}
How can I fix this?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Post Reply