dongwei3172 2012-03-22 08:15
浏览 43
已采纳

我的登录脚本在本地服务器上工作正常,但它不能在实时服务器上运行

I am using my admin panel login script where i have created a global.php file with code including this:-

<?php

$Global['host']="localhost";
$Global['username']="username";
$Global['password']="*******";
$Global['database']="database_name";
$Global['baseurl']='www.somesite.com/work/';

$connhandle=mysql_connect($Global['host'],$Global['username'],$Global['password'])or  die('can\'t establish connection with mysql database');
$dbSelect=mysql_select_db($Global['database'],$connhandle) or die('could not connect to the database');
?>

and for calling the script on clock i m using a redirect.php file which include code as follows:-

<?php
session_start();
$_SESSION['username'] = $_POST['user'];
$_SESSION['password'] = $_POST['pass'];
$_SESSION['aid'] = 0;

include 'global.php';

$admin_themes=mysql_fetch_object(mysql_query("select * from admin where id='1'"));

$ruser = $admin_themes->username;
$rpass = $admin_themes->password;

if ($_SESSION['username'] == $ruser && $_SESSION['password'] == $rpass) {
$_SESSION['aid'] = 1;
header("location:../index.php");
}
else {
header("location:../admin_login.php?passcheck");
}
?>

no this scripts in working absolutely fine when i run this using my xampp server on local. but when i upload it to my online server the redirect script show me this error:-

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'username'@'localhost' (using password: YES) in /home/..../public_html/work/h_cms/configuration/global.php on line 9 can't establish connection with mysql database

any suggestion why its not showing on online server i have used the correct username and pass of my database i have checked it 5 times. But still not find where is the problem.

  • 写回答

2条回答 默认 最新

  • duanji4449 2012-03-22 08:23
    关注

    username@localhost is clearly not the correct username based on the error message. if you're subscribing to a hosting provider, you may want to check with them the correct username for your mysql account.

    also, you might want to try using your domain name instead of localhost.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?