Page 1 of 1

ignore a hyphen in a name

Posted: Thu Sep 18, 2014 7:33 am
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

Re: ignore a hyphen in a name

Posted: Thu Sep 18, 2014 8:20 am
by pbs
show us the code

Re: ignore a hyphen in a name

Posted: Thu Sep 18, 2014 8:22 am
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?