Some code execution problems

Source: Internet
Author: User
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];}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.