ignore a hyphen in a name

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
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

ignore a hyphen in a name

Post by jonnyfortis »

i have a name John O'Smith that is stored in my DB but when i am echoing it out i am getting the error

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 'Smith'' at line 1

what do io do rather than chaning the name
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: ignore a hyphen in a name

Post by pbs »

show us the code
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: ignore a hyphen in a name

Post by Celauran »

I can see where you might encounter some issues in querying it, if you're wrapping strings in single quotes. For that I'd recommend prepared statements. Indeed, for most queries I'd recommend prepared statements.

Your post suggests you're running into problems when echoing out the results of a query, which is odd. Maybe post the code in question and exactly where the error is occurring?
Post Reply