Inserting ' into mysql fields

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
eyal
Forum Newbie
Posts: 19
Joined: Mon Jun 19, 2006 11:03 am

Inserting ' into mysql fields

Post by eyal »

Hello,

When I'm inserting the char ' php thinks I'm done writing, altough it's only part of my sentence.

For example, if I have a want to enter a sentece: I'm here
Php will read it like this

Code: Select all

mysql_query("INSERT INTO table(field) VALUES('I'm here')")
What should I do?

Thank you.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

eyal
Forum Newbie
Posts: 19
Joined: Mon Jun 19, 2006 11:03 am

Post by eyal »

Thank you, Altough I'm having an error when I'm using the function:
Fatal error: Call to undefined function: mysql_real_escape_string() in c:\apache\htdocs\direct_site\try3\3.php on line 45
After I wrote:

Code: Select all

$var=mysql_real_escape_string($var);
Any Idea what should I do?

Thank once again.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

It would appear you're using a fairly old version of PHP. mysql_escape_string() then.
Post Reply