PHP Read access DB instance code

Source: Internet
Author: User
PHP Read access DB instance code

 Open ($MM _conn_string);//link opens data source $query= "SELECT * from DM ORDER by ID ASC"; $RS->open ($query, $Conn, 1, 1);//EXECUTE statement, Returns the data set echo "Total:". $RS->recordcount. " Record results!
"//Record number for ($i =0; $i < $RS->fields->count; $i + +) echo $RS->fields[$i]->name." ";//Traverse field name echo"
"; $connect = mysql_connect (" 192.168.0.51 "," username "," password "), while (! $RS->eof) {$query =" INSERT INTO smsgames.nanjing_toponym values (' "; $query. = $RS->fields[" id "]->value." ', ' "; $query. = $RS->fields[" Name "- >value. "', '"; $query. = $RS->fields["symbol"]->value. "', '"; $query. = Str_replace ("\ r \ n", "", $RS->fields[ "Weizhi"]->value). "', '"; $query. = $RS->fields["" "" "" "]->value." ', ' "; $query. = $RS->fields[" Class "]-> Value. "', '"; $query. = Str_replace ("\ r \ n", "", $RS->fields["History"]->value). "', '"; $query. = Str_replace ("\ r \ n "," ", $RS->fields[" addr "]->value). $result = mysql_query ($query, $connect), if (! $result) print "Error:". Mysql_error (). "
Query: ". $query."
"; Elseprint $RS->fields[" id "]->value." "; $RS->movenext (); $i + +;} Release resources $conn->close (); $RS =null; $Conn =null;? >
  • 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.