When Ajax is used for interaction, garbled characters such ???????????? Solutions for such records

Source: Internet
Author: User

Mysql_query ("set names 'gbk
'") Or die (error (mysql_error ()));

 

 

$ Db = new mysqli ('192. 168.200.254 ', 'dxy', 'p0o9i8u7', 'pattern'); <br/> If (! $ DB) {<br/> // show error if we cannot connect. <br/> echo 'error: cocould not connect to the database. '; <br/>} else {<br/> // is there a posted query string? <Br/> If (isset ($ _ post ['querystring']) {<br/> $ querystring = $ db-> real_escape_string ($ _ post ['querystring']); </P> <p> // is the string length greater than 0? </P> <p> If (strlen ($ querystring)> 0) {<br/> $ db-> query ("set Character Set utf8 "); <br/> $ query = $ db-> query ($ query = "select patent_id, patent_name from list_id where patent_id like '% $ querystring % 'limit 6 "); <br/> if ($ query) {<br/> // while there are results loop through them-fetching an object (I like PhP5 BTW !). <Br/> while ($ result = $ query-> fetch_object () {<br/> echo "<li onclick = fill ('". $ result-> patent_id. "^ ". $ result-> patent_name. "');> ". $ result-> patent_id. "<br/> ". $ result-> patent_name. "</LI>"; <br/>}< br/>} else {<br/> echo 'error: there was a problem with the query. '; <br/>}< br/>} else {<br/> // dont do anything. <br/>} // There Is A querystring. <br/>} else {<br/> echo 'there shocould be no direct Access to this script! '; <Br/>}< br/>}

 

 

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.