Membership is FREE, giving all registered users unlimited access to every Acorn Domains feature, resource, and tool! Optional membership upgrades unlock exclusive benefits like profile signatures with links, banner placements, appearances in the weekly newsletter, and much more - customized to your membership level!

php mysql select query question

Status
Not open for further replies.
Joined
Jan 19, 2007
Posts
2,207
Reaction score
47
Is it possible to select a row with name = "bob's chocolates" when the variable you have is "bobs-chocolates"

my issue isn't the hyphen (which I can do the preg_replace() )
but is the ' which has already been stripped and I don't know where to insert it to get a 100% match ?

I know that when I'm selecting all names that begin with the same letter I use LIKE:

SELECT * FROM table WHERE name LIKE '$name%'

Is there a similar query that will negate apostrophes or other characters?
 
Think I've figured it out:

SELECT name WHERE replace(name,'''','') = 'bobs chocolates'
 
skinner you're like a walking php phrasebook. I'll take a look at the link. Thanks.
 
Pay special attention to things like Soundex :)

You'll pick all these things up :)

Just wait until your left broken and deflated because you missed a " or ' or ; or } or ) somewhere in the code and you stare at it for 3 days and are unable to see it, you'll soon realise that remembering stuff like this is easy :p
 
I'm usually pretty quick at the ,{; problems

Probably because my projects are often small and I check small code changes religiously - so I can rollback the last change.

I'm really excited about my current project though - the one that you've helping me out a bit on. Will probably post it on Acorn for appraisal and ideas in the next day or 2.
 
I try to include global debug variables.

randomly insert

if($debug==1){ ehco "debug X routine, value: $var";}

Then at the top of my script I have $debug=0;

That way when something goes wrong I can see where it went wrong very quickly, but other people don't want stuff like that in their code they want lean fast code so I have to take all the debug stuff out before I deliver it, then when I get 1000 lines of code back for updates I'm screwed if they have modded it as well :p

The last project I'm working on that I may post on here, is the one I'm usin for the 'For Sale' links in my sig which the core program I posted http://www.acorndomains.co.uk/general-board/45790-parking-vs-sale-landing-page-vs-2.html you can see the debug code there.

That took me a few hours to put together :)
 
Status
Not open for further replies.

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Members online

No members online now.

Premium Members

New Threads

Domain Forum Friends

Our Mods' Businesses

*the exceptional businesses of our esteemed moderators
General chit-chat
Help Users
  • No one is chatting at the moment.
      There are no messages in the current room.
      Top Bottom