help in apostrophes

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
tabatsoy
Forum Commoner
Posts: 29
Joined: Thu Mar 13, 2008 10:14 am

help in apostrophes

Post by tabatsoy »

greetings Earthlings!!!!

when i put an apostrophe on my form(eg. o'mg) and hit submit button it says "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''''' at line 5"

Please Help
hansford
Forum Commoner
Posts: 91
Joined: Mon May 26, 2008 12:38 am

Re: help in apostrophes

Post by hansford »

use addslashes() on all of your $_POSTS before querying or adding to DB, then use stripslashes() when pulling them out of DB
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: help in apostrophes

Post by superdezign »

Use mysql_real_escape_string() instead of addslashes().
tabatsoy
Forum Commoner
Posts: 29
Joined: Thu Mar 13, 2008 10:14 am

Re: help in apostrophes

Post by tabatsoy »

thanks earthlings

i love this planet :crazy:
hansford
Forum Commoner
Posts: 91
Joined: Mon May 26, 2008 12:38 am

Re: help in apostrophes

Post by hansford »

well I've being countered by superdezign on my last 2 posts so, I will have to re-evalute my responses befoe posting. I have < 100 and he has > 3000, who you gunna trust?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: help in apostrophes

Post by superdezign »

Hehe, we all learn from each other. Most of what I know, I learned here.
Even if you are wrong (or in your cases, just slightly off), posting what you think is right is the best way to find out what actually is right.
hansford
Forum Commoner
Posts: 91
Joined: Mon May 26, 2008 12:38 am

Re: help in apostrophes

Post by hansford »

This article is worth reading and a good example of why I took back my comment on using addslashes() after superdezigns remarks.

http://shiflett.org/blog/2006/jan/addsl ... ape-string
Post Reply