gpt4 book ai didi

php - 我的登录脚本在本地服务器上工作正常,但在实时服务器上无法工作

转载 作者:行者123 更新时间:2023-11-29 08:56:36 25 4
gpt4 key购买 nike

我正在使用我的管理面板登录脚本,其中我创建了一个 global.php 文件,其中包含以下代码:-

<?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');
?>

为了在时钟上调用脚本,我使用了一个redirect.php 文件,其中包含如下代码:-

<?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");
}
?>

当我在本地使用我的 xampp 服务器运行此脚本时,此脚本工作得绝对正常。但是当我将其上传到我的在线服务器时,重定向脚本向我显示此错误:-

警告:mysql_connect() [function.mysql-connect]:/home/..../public_html/work/h_cms/configuration/中的用户“用户名”@“localhost”(使用密码:YES)访问被拒绝global.php 第 9 行无法与mysql数据库建立连接

任何建议为什么它没有显示在在线服务器上我已经使用了正确的用户名和数据库密码我已经检查了 5 次。但还是没找到问题出在哪里。

最佳答案

根据错误消息,username@localhost 显然不是正确的用户名。如果您订阅了托管提供商,您可能需要向他们核实您的 mysql 帐户的正确用户名。

此外,您可能想尝试使用您的域名而不是本地主机。

关于php - 我的登录脚本在本地服务器上工作正常,但在实时服务器上无法工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9818545/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com