Table of Contents
例子
Home php教程 php手册 unity访问php

unity访问php

Jun 06, 2016 pm 07:36 PM
php unity no networking access connect

长连接,弱联网。不好意思,这俩不是一个意思。 反过来说,短连接,强联网,是不是有点别扭呢。 你可以不会php,甚至你可以不知道php是干什么的。 百度php安装环境,自行搭建好环境,顺便测试一下。(下载那个XAMPP,数据库也是弄好的) 百度连接mysql数据库

长连接,弱联网。不好意思,这俩不是一个意思。

反过来说,短连接,强联网,是不是有点别扭呢。

你可以不会php,甚至你可以不知道php是干什么的。

百度php安装环境,自行搭建好环境,顺便测试一下。(下载那个XAMPP,数据库也是弄好的)

百度连接mysql数据库

会找到如下代码,具体的可能会有差别,反正你测试连接成功就行

例子

下面的例子选取存储在 "Persons" 表中的所有数据(* 字符选取表中所有数据):

<?php $con = mysql_connect("localhost","peter","abc123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("my_db", $con);

$result = mysql_query("SELECT * FROM Persons");

while($row = mysql_fetch_array($result))
  {
  echo $row['FirstName'] . " " . $row['LastName'];
  echo "<br />";
  }

mysql_close($con);
?><br><span>继续,然后添加两个变量记录POST请求过来的数据,顺便自行创建好相应的数据库</span><br><span>代码用文本文档编写即可。</span>
Copy after login
<?php <br />$First = $_POST["Firstname"]<br>$Last = $_POST['Lastname']<br>
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("my_db", $con);

$result = mysql_query("SELECT * FROM Persons WHERE FirstName = '$Fires' AND Last = '$Last'");

while($row = mysql_fetch_array($result))
  {
  echo $row['FirstName'] . " " . $row['LastName'];
  echo "<br>";
  }

mysql_close($con);
?><br><span>储存,后缀改为.php的,放到XAMPP中对应的文件夹内</span><br><span>unity内新建脚本</span><br><span>using UnityEngine;<br>using System.Collections;<br><br>public class TestConnectPHP : MonoBehaviour {<br><br>    public string username;<br>    public string password;<br>    // Use this for initialization<br>    void Start () {<br>        StartCoroutine (Select());<br>    }<br>    <br>    // Update is called once per frame<br>    void Update () {<br>    <br>    }<br><br>    IEnumerator Select()<br>    {<br>        WWWForm select = new WWWForm ();<br>        select.AddField ("Firstname",username);<br>        select.AddField ("Lastname",password);<br><br>        WWW www = new WWW ("http://localhost/testdatabase.php",select);<br>        yield return www;<br>        print (www.text);<br>    }<br>}<br>运行,看结果<br></span><br><br><br>
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

See all articles