removing quotes from a database query

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
User avatar
hyper_st8
Forum Newbie
Posts: 20
Joined: Mon Aug 18, 2003 5:27 am
Contact:

removing quotes from a database query

Post by hyper_st8 »

Hi,
Just a short question:

If you are selecting a field from a database, where you are using LEFT() to display only the variables that match that first letter, i.e.

$query = "SELECT names FROM table WHERE LEFT(names, 1) = 'a' ORDER BY names ASC";

But within the database one of the names has quotes arround them, how would you get this to still show up that name when it is being listed?

Thank you in advance!
User avatar
delorian
Forum Contributor
Posts: 223
Joined: Sun May 04, 2003 5:20 pm
Location: Olsztyn, Poland

Re: removing quotes from a database query

Post by delorian »

I do not know for sure, but it may works:

Code: Select all

$query = "SELECT names FROM table WHERE LEFT(names, 1) = 'a' OR LEFT(names,2) = '"a' ORDER BY names ASC";
User avatar
hyper_st8
Forum Newbie
Posts: 20
Joined: Mon Aug 18, 2003 5:27 am
Contact:

Post by hyper_st8 »

Cheers for that! It works brilliantly! :D
Post Reply