PHPcode & lt ;? Php $ DBserver & quot; localhost & quot; $ DBname & quot; new & quot; $ DBuser & quot; root & quot; $ DBpassword & quot; & quot; code execution problems
PHP code
805) {$ h = ($ m [2] * 805)/$ m [1]; $ k = 805; $ ptext = preg_replace ('/(width =) "(\ d +)" (\ s * height =) "(\ d +)"/I ',' $1 "'. $ k. '"$3 "'. $ h. '"', $ m);} mysql_query (" set names 'gbk' "); $ SQL =" update pagecontents set page_text = ('{$ ptext }') where page_id = ('{$ pid}') "; mysql_query ($ SQL) or die (mysql_error () ;}?>
The result is that both sentences are executed.
HTML code
// Part of page_text ////
Originally, we wanted to change only the one with a width greater than 805, that is, the first one. all the results were replaced.
------ Solution --------------------
$ M [1] returns all matched content.
Print_r. you can see it.
------ Solution --------------------
The problem has not been solved yet? You pasted several paragraphs. That section is the standard. The problem is not clearly described.
------ Solution --------------------
Remember I wrote code to you.
PHP code
$ Page_text = <TXT; echo preg_replace_callback ('# width = "(\ d +)" \ s * height = "(\ d +)" # I ', 'back', $ page_text); // $ m [1] indicates the width value, and $ m [2] indicates the height value. Function back ($ m) {if ($ m [1]> 805) {$ h = round ($ m [2] * 805)/$ m [1]); $ k = 805; return "width = \" $ k \ "height = \" $ h \ "";} return $ m [0];}