尝试在免费虚拟主机上将我的数据库连接到我的网站

时间:2016-10-27 18:42:53

标签: mysql web-hosting

这是我第一次尝试在免费虚拟主机上传我的网页,我能够在http://anime4life.freecluster.eu/上传所有文件和数据库现在我的连接仍然在localhost上,所以我收到了一个错误加载数据库所以我的问题是如何在我的localhost上正确设置我的连接我使用这行代码

<?php

ini_set('display_errors', 'On');
ini_set('file_uploads', 'On');
define('APP_ROOT', __DIR__);
define('VIEW_CONFIG', APP_ROOT. '/config');
define('VIEW_CONTENTS', APP_ROOT. '/contents');
define('VIEW_IMAGES', APP_ROOT. '/images');
define('VIEW_SCRIPT', APP_ROOT. '/script');
define('BASE_URL', 'http://localhost/Anime4Life');

$db = new PDO('mysql:host=localhost;dbname=myanimelist','root','');



require '/functions.php';
if(session_status()== PHP_SESSION_NONE)
{
    session_start();
}
?>   

现在尝试更改localhost和db以运行网页

$db = new PDO('mysql:host=anime4life.freecluster.eu;dbname=fceu_19082010_myanimelist','root','');

我仍然遇到错误

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] Connection refused' in /home/vol13_3/freecluster.eu/fceu_19082010/htdocs/config/start.php:12 Stack trace: #0 /home/vol13_3/freecluster.eu/fceu_19082010/htdocs/config/start.php(12): PDO->__construct('mysql:host=anim...', 'fceu_19082010', 'c2a3r1l1475') #1 /home/vol13_3/freecluster.eu/fceu_19082010/htdocs/index.php(4): require('/home/vol13_3/f...') #2 {main} thrown in /home/vol13_3/freecluster.eu/fceu_19082010/htdocs/config/start.php on line 12

任何想法我将做什么,如果我在第一次尝试时犯了很多错误,请继续前进

我的虚拟主机(infinityfree.net)的其他信息可以帮助您解决我的问题

Main Domain lvfw2yko.freecluster.eu
FTP hostname:   ftp.freecluster.eu
FTP username:   fceu_19082010
MySQL hostname: sql311.freecluster.eu
MySQL username: fceu_19082010
Hosting Volume  vol13_3
Home Directory:
/home/vol13_3/freecluster.eu/fceu_19082010

FTP user name   fceu_19082010
FTP password    Same as your cpanel password
FTP host name   ftp.freecluster.eu
FTP port    21

MySQL Settings

MySQL user name fceu_19082010
MySQL password  Same as your cpanel password
MySQL host name sql311.freecluster.eu
MySQL port  3306

0 个答案:

没有答案