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条)

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集