常规服务器连接问题 [英] General server connection question

查看:85
本文介绍了常规服务器连接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,伙计们

我对php东西还很陌生,所以请帮帮我.

我对服务器的连接有一个简单的问题.我需要从家用笔记本电脑连接到学校的服务器,我拥有在该服务器上使用的联合国密码Mysql db.我如何从我的PHP脚本连接到该服务器,说该服务器地址是a.b.mmit.edu,类似这样.我知道我不能使用localhost,因为这意味着我正在使用本地数据库,但是要使用学校的数据库,我应该怎么做才能使用php进行连接.

请问这是怎么做的?

Hey there guys

I am quite new to php stuff so please help me out.

I have a simple question on connectivity to the server. I need to connect to my school''s server from my home laptop, i have the UN, Password for the Mysql db that i need to use in that server. How can I connect to that server from my PHP script, say the server address is a.b.mmit.edu , something like that. I know I can''t use localhost because it means i am using my local database, but to use the school''s db what should i do to connect using php.

is this how to do it??

$connection = mysql_connect("a.b.mitt.edu","user",'pass');

推荐答案

connection = mysql_connect(" " ' pass' );
connection = mysql_connect("a.b.mitt.edu","user",'pass');


尝试从脚本访问该数据库之前,请首先确保可从您的PHP引擎所在的服务器访问该数据库.某些服务器对IP地址有限制,这些IP地址可能出于安全目的而访问特定服务器.
Before attempting to access that database from your script, first ensure that the database is accessible from the server at which your PHP Engine is located. Some servers have restrictions to the IP Addresses that may access the specific server for security purposes.
<?php
//This will connect you to the server, and if it fails, you will get the error message telling you why


连接 = mysql_connect(" 用户名" 密码")" MySQL错误:" .mysql_error()); // 这会将您连接到所选数据库,如果失败,您将收到一条错误消息,说明原因
connection = mysql_connect("host_name", "username", "password") or die("MySQL Error: ".mysql_error()); //This will connect you to the selected database and if it fails, you will get an error message giving you the reason


这篇关于常规服务器连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆