unity访问php
长连接,弱联网。不好意思,这俩不是一个意思。 反过来说,短连接,强联网,是不是有点别扭呢。 你可以不会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>
<?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>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

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

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

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

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

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

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

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

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