Jump to content

Single quote


Cyto

Recommended Posts

Hi,

 

I'm trying to delete a string that's single quoted. From: Cyto's to Cyto, but doesn't work. It works when I add 's to the string with stripslashes, but I can't seem to delete a quote from a string.

Does someone know how?

 

My $_post code:

$name=mysql_real_escape_string(stripslashes($_POST["ename"]));

 

Cheers

 

Link to comment
https://forums.phpfreaks.com/topic/245395-single-quote/
Share on other sites

Your trying to delete a row from your database based on the name value? We would need to see how it is stored in the database. Is it stored as Cyto's or Cyto/'s?

It's stored as Cyto and I add 's, it becomes Cyto's. Ok it works, but when I want to delete a row with 's in a string(Cyto's), it returns as Cyto's back instead of Cyto.

 

P.S Cyto as string is a example, there are other words.

Link to comment
https://forums.phpfreaks.com/topic/245395-single-quote/#findComment-1260378
Share on other sites

Please post the rest of the code. I don't know what you are trying to do right now. Please post code, don't just try to restate what you just said.

 

I'm trying to delete a row with a quote in a string and add a row with a quote in a string. The adding works with stripslashes, but the deleting part... I'm stuck there.

Link to comment
https://forums.phpfreaks.com/topic/245395-single-quote/#findComment-1260475
Share on other sites

Maybe:

 

UPDATE `table` SET `string` = REPLACE(`string`, "'", '')

 

If you need some kind of filtering add a WHERE clause.

Thx, but nvm. I figured it out myself. I added mysql_real_escape_string() in the where clause. It added a slash to the quoted strings. Worked.

Thank you too, teynon.

Link to comment
https://forums.phpfreaks.com/topic/245395-single-quote/#findComment-1260479
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.