您好这个脚本我试图远程测试MySQL连接,如果我的VPS打开或不打开,因为我需要远程使用一些表信息。 这个脚本工作在WAMP(本地)和directadmin(互联网),它的显示远程连接在我的VPS上打开,但是使用cpanel我有这个错误。
Unable to Connect to 'my_vps_ip'
我的脚本安装在Cpanel上,所以我需要从Cpanel主机远程连接到我的VPS。 我的问题是,如果需要在Cpanel中启用某些东西来处理这个脚本吗?
$dbname = 'b3';
$dbuser = 'user';
$dbpass = 'pass';
$dbhost = 'my_vps_ip';
$connect = mysql_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to '$dbhost'");
mysql_select_db($dbname) or die("Could not open the db '$dbname'");
$test_query = "SHOW TABLES FROM $dbname";
$result = mysql_query($test_query);
$tblCnt = 0;
while ($tbl = mysql_fetch_array($result)) {
$tblCnt++;
#echo $tbl[0]."<br />\n";
}
if (!$tblCnt) {
echo "There are no tables<br />\n";
} else {
echo "There are $tblCnt tables<br />\n";
}
有关详细信息,请查看以下2个链接:
1)在我的directadmin面板中:http://plusmaster.ir/test.php工作
2)在我的Cpanel主持人中:http://xlrstats.ir/app/webroot/con.php无法工作