DirectAdmin mysql 连接到统一游戏问题

DirectAdmin mysql connect to unity game problem

我编写了一个脚本来收集游戏中的电子邮件和分数并将其发送到数据库。到目前为止,在开发过程中我使用了 MAMP,一切正常。现在我将构建上传到 direct admin,在 phpmyadmin 上设置数据库,在我的 php 文件中更改数据库名称密码等,但它不起作用!我已将所有文件放在 ftp 中的同一文件夹中(统一构建文件和一个包含 php 脚本的 sqlconnect 文件夹)但是是的,它不会更新数据库。

这是database.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Networking;
public class Database : MonoBehaviour
{
public InputField emailField;
public InputField inputFieldRef;   
public Button submitButton;
// Start is called before the first frame update
public void CallSignup()
{
    StartCoroutine(Signup());
}

IEnumerator Signup()
{
    WWWForm form = new WWWForm();
    form.AddField("email",emailField.text);
    emailField.text = string.Empty;
    form.AddField("score",GameManager.score);
    UnityWebRequest www = UnityWebRequest.Post("http://localhost/sqlconnect/signup.php",form);
    yield return www.SendWebRequest();
    
    if(www.isNetworkError || www.isHttpError) {
        Debug.Log(www.error);
    }
    else {
        Debug.Log("Form upload complete!");
    }
}
public void VerifyInput()
{
    submitButton.interactable = (emailField.text.Length >= 8);
}
}

这是我的 php 文件

<?php

$servername = "localhost";
$username = "database username";
$password = "password";
$dbname = "database";

$conn = mysqli_connect($servername,$username,$password,$dbname);

if (mysqli_connect_errno())
{
    echo "1: Connection Failed";
    exit();
}

$email = msqli_real_escape_string($conn, $_POST["email"];
$emailclean = filter_var($email,FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | 
FILTER_FLAG_STRIP_HIGH);
$score = $_POST["score"];

$updatequery = "UPDATE testscore SET score='$score' WHERE email ='$email'";
mysqli_query($conn , $updatequery) or die("FAILED ".__LINE__." : ".mysqli_error($conn));

echo "0";

?>

在 运行 检查员之后我再次看到,因为我没有打开通配 DNS,所以无法连接和显示。所以我添加了 header

header('Access-Control-Allow-Origin: *');

header('Access-Control-Allow-Methods: GET, POST');

header("Access-Control-Allow-Headers: X-Requested-With");

我现在可以看到一切正常