Mysql Escape function; Generate Update Query by using Select Query -


hello have development server , production server on both same databases. table products edited on both servers on different columns development: id model image production: price , out_of_stock

i don't want use php this.

so have created following query development server

select concat( "update `products` set `products_id` = ", products_id, ",`products_model` = '", replace( products_model, "'", "\'" ) , "',`products_image` = '", products_image, "' `products`.`products_id` = ", products_id, ";" ) `products`  

this query return me query production sever

update `products` set `products_id` = 60,`products_model` = 'ct'257',`products_image` = 'ct_black01.jpg' `products`.`products_id` = 60; update `products` set `products_id` = 59,`products_model` = 'ct"255',`products_image` = 'ct_black01.jpg' `products`.`products_id` = 59; update `products` set `products_id` = 58,`products_model` = 'ct/242',`products_image` = 'ct_black01.jpg' `products`.`products_id` = 58; update `products` set `products_id` = 57,`products_model` = 'ct221',`products_image` = 'ct_black01.jpg' `products`.`products_id` = 57; 

the problem need escape fields when product_model contain ' or " or both query fail

how can mysql_real_escape without php?

thank you

how about

replace(replace(products_model, "'", "\\'"), '"', '\\"') 

this replace single , double quotes escaped single , double quotes.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -