cocos2dx-3.3 Network Programming (curl+php) the best to write PHP code

Source: Internet
Author: User
Tags deprecated
In order to try the network programming, read a lot of great God's blog, now this record to prevent forgetting.


We have to do a few things before we write the connection code:

1. Build Wamp

2. Create a database

3. Write the PHP code well

4. Testing


A: Build Wamp

Wamp construction is very convenient, download and installation can be


Two: Create a database


(Sorry password wrong, here to explain, the following password are wrong!) )


Three: Write good PHP code check.php:

 
  Deprecated:mysql_connect (): The MySQL extension is Deprecated and would be a removed in the Future:use MySQL ...  $US =$_get["name"];  Get data with Get $ps= $_get["Passward"];  1. Connect the database  $conn = mysql_connect ("127.0.0.1", "root", "123456");  2. Open  the database mysql_select_db ("testphp");  3. Create a new query  $sql = "SELECT * from users WHERE name = '". $US. "' and Passward = ' ". $ps. "';";    4. Execute this query  $result = mysql_query ($sql);  $n = mysql_num_rows ($result); Returns the number of results found  //5. Close Database  mysql_close ($conn);  if ($n >0)//If the number of results found is greater than 0, that is, the user name and password with the passed in parameters one to  {      session_start ();      $row = Mysql_fetch_array ($result);  Get query results that line  //var_dump ($row);//Output query results, there is no need for    echo "1";    The server returns the client a "1"  }  else  {      echo "0";  No results found, return "0"  }  ?>  

Four: Testing

Now in the browser to enter: http://127.0.0.1/check.php?name=banana&passward=123456

See if it returns a "1" and if so, then the first step is successful.



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

  • 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.