Jump to content

Escaping Regex


Mike Solstice

Recommended Posts

Ok, that works if I run it CLI or though phpMyAdmin, but won't if I try it in php

 

$remcomma = "UPDATE top_train SET deaths = replace( replace(field_name, ',', ''), '"', '' )";
mysql_query($remcomma);

 

I assume because of the quotes used in the regex. I tried escaping the "

 

$remcomma = "UPDATE top_train SET deaths = replace( replace(field_name, ',', ''), '\"', '' )";
mysql_query($remcomma);

 

Which broke it altogether. Anyone have any ideas?

 

Thanks!

 

Moved here since that thread was marked as solved & it's more of a PHP issue at this point anyway. Any & all help is greatly appreciated!

Link to comment
Share on other sites

Sorry, kind of assumed people would go read the thread that quote is linked to ;)

 

I have a MySQL column that was created as VARCHAR and has numeric entries that contain commas. I need to convert that to INT in order to be able to use the data in calculations, but need to strip the commas out before I can convert to INT otherwise it just cuts off at the comma & I loose the rest of the data.

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.