Jump to content

how to comment out an apostrophy in an sql statement


paul2463

Recommended Posts

Hello everyone, I am sorry if this question has been asked a million times, but this is the first time I have come across this problem.

I have the end part of a  sql query that is being passed across pages( form a "table filter" type function)

it turns up looking like this
[code]
WHERE products.nameProd = \'3\' TUDOR\'
[/code]
mysql needs it to look like this
[code]
WHERE products.nameProd = '3\' TUDOR'
[/code]
I could always ask that entries in feet dont use the ' , but use "feet" instead, but it would be nicer to be able to remove the first and last "\" but leave the middle one intact. I have a pattern which strips out all the "\" but that obviously brings out mysql errors because it needs the middle one, any help gratefully recieved.
Link to comment
Share on other sites

thanks for that and it works, to an extent.. I have tried using addslashes but the problem is that i need the two apostophes either side of the string '3'TUDOR' to remain as apostophes, but I need the middlw one slashed out. I have written a couple of functions for myself, as I know the itinerant apostrophe will always come after a number like 4'6 or 3' table etc etc I wrote a function that iterated along the string and if there were any apostrophes following directly behind a number it split the string added a "\" and the rebuilt the string. works for me

thanks anyway
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.