- 最后登录
- 2018-5-18
- 注册时间
- 2014-1-21
- 阅读权限
- 10
- 积分
- 88
- 纳金币
- 2
- 精华
- 0
|
申请了个网站空间(云动力的)做测试,把本地做好的文件上传到网站连不上,连接改了估计是不到位大家帮忙看看!*******************************************************************************************
开始在本地测试很好一点问题也没,一上到网络空间就有问题想请教大家指点下,困扰几天了
连接网络有两个问题请教(我是学美术的,希望大家不要笑话我!):
1、数据库我是从PHPadmin管理:http://111.229.239.249:999进入建立的,这样做完不知道数据库位置是不是对的?是不是要放到ftp目录下的databases里面,还是建好就不管了?
2、下面php代码里面连接数据库和unity3d代码中连接地址不知道对不对。帮忙看看各位高手!!
*******************************************************************************************
下面是我网站的基本情况
送的三级域名假设是 :wsk94.ydlkfree1.tzhytl.com
ip :111.229.239.249
假设
PHPadmin管理:http://111.229.239.249:999
数据库地址:111.229.239.249
数据库名称:sp_wsk94
数据库用户名:sp_wsk
数据库密码:123456
假设
网站ftp地址:111.229.239.249
用户名:haha
密码:123
网站目录结构
数据库结构
php代码如下,已经拷贝到ftp的wwwroot下了- <?
- // 连接数据库
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$host = "111.229.239.249"; //主机名
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$user = "sp_wsk"; //用户名
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$password = "123456"; //密码
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$dbname = "sp_wsk94"; //数据库名称
- mysql_connect($$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$host, $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$user, $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$password) or die("Cant connect into database");//连接失败输出错误提示
- mysql_select_db($$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$dbname)or die("Cant connect into database");
- // =============================================================================
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$unityHash =$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$_POST["hash"];//接收unity3d发送给程序的哈希值
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$phpHash = "hashcode"; //另外,要说的是hash值在此其实相当于二重保险,避免sql注入
- //所以为了简化程序我这里也去了,只要保证unity3d和php内的哈希值相等即可
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$nick = $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$_POST["name"]; //接收unity3d发送给程序的用户名
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$pass = $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$_POST["password"];//接收unity3d发送给程序的密码
- //先判断发送值是否为空
- if(!$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$nick || !$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$pass)
- {
- echo "昵称或密码不能为空!";//昵称或密码不能为空。
- } else
- {
- if ($$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$unityHash != $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$phpHash)
- {
- echo "HASH code is diferent from your game, you infidel.";//判断哈希值是否相等
- } else
- {
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$SQL = "SELECT * FROM `scores` WHERE `scores`.name = '" . $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$nick . "' and `scores`.password = '".$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$pass."'";//查看用
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$result = mysql_query($$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$SQL) or die("DATABASE ERROR!");
- if(mysql_num_rows($$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$result)==0)//php函数
- {
- echo "昵称或密码错误!"; //输出昵称或密码错误
- }else
- {
- echo "Welcome to unity3D !\n";//成功提示,“\n”只是为了能在unity中实现换行
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$sql = "SELECT * FROM `scores` WHERE `scores`.name = '" . $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$nick . "' and `scores`.password = '".$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$pass."'";
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$result = mysql_query($$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$sql);
- while($$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$row = mysql_fetch_array($$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$result))//输出用户表信息
- {
- echo "ID:".$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$row['id']."\n";
- echo "NAME:".$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$row['name']."\n " ;
- echo "PASSWORD:".$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$row['password']."\n ";
- echo "INFO:".$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$row['info']."\n ";
- }
- }
- }
- }
- // Close mySQL Connection
- mysql_close();
- ?>
复制代码 unity 3D js代码- #pragma strict
- private var formName = "";//创建私有变量formName,记录文本框内输出的用户名变量
- private var formPassword = "";//创建私有变量 formPassword记录文本框内输出的密码变量
- var formText = "";//创建变量formText显示php发送给web端的信息
- var URL = "http://111.229.239.249/wsk94/wwwroot/check.php";//提交表单的网址
- var hash = "hashcode";//与php中相同的哈希值
- private var textrect = Rect (10, 150, 500, 100); //建立GUI的文本输入框
- function OnGUI()
- {
- GUI.Label( Rect (10, 10, 80, 20), "姓名:"); //用户名
- GUI.Label ( Rect (10, 30, 80, 20), "密码:" );//密码
- formName = GUI.TextField ( Rect (90, 10, 100, 20), formName ); //这里,你可将你输入的用户名赋值给formName变量
- formPassword = GUI.PasswordField ( Rect (90, 30, 100, 20), formPassword ,"*"[0], 25);
- //同理,这里是给formPassword 赋值
- if ( GUI.Button ( Rect (10, 60, 100, 20) , "登录" ) )
- { //如果单击登录按钮会执行Login()函数
- Login();
- }
- GUI.TextArea( textrect, formText );//显示文本信息
- }
- function Login()
- {
- var form = new WWWForm();//建立新表单变量
- //print(hash);//print的内容会在console选项卡中输出
- //print(formName);//我在这里添加三个输出语句是为了检验用户名和密码是否复制正确,以便之后调试php文件
- //print(formPassword);
- form.AddField("hash",hash);//创建表单各项
- form.AddField("name",formName);
- form.AddField("password",formPassword);
- var w = WWW(URL,form);//建立名为“w”的变量,并且将表单提交的URL和表单内容同步
- yield w;//我们等待表单响应php程序的返回,让程序把控制权交给其他应用
- if(w.error != null)//如果返回信息为错误信息,在console中输出错误信息
- {
- print(w.error);
- }
- else
- {
- print("OK!");//在console中输出ok
- formText = w.text;//将返回的web短信息赋值给formText ,在 执行GUI.TextArea( textrect, formText );时输出
- }
- formName = "";//点击查询完用户信息后清空用户名及密码
- formPassword = "";
- }
复制代码 |
|