gpt4 book ai didi

php - MySQL 查询在本地主机上工作正常,但在服务器上不行

转载 作者:行者123 更新时间:2023-11-29 12:45:52 25 4
gpt4 key购买 nike

我的查询在本地主机上运行得非常好,但是当我在服务器上执行此操作时,查询成功通过,但是它将我自己重定向到 login.php 并显示登录查询,而不是转到welcome.php页面

假设当我输入用户名/密码时,它会将自己重定向到 login.php成功的 MySQL 语法查询..并在屏幕上显示查询

就像我的用户名是 v@v.com密码v然后按下登录按钮后,它会将我重定向到login.php,而不是welcome.php,在屏幕上显示类似此查询的查询

SELECT * FROM members WHERE username = 'v@v.com' AND pas = '7a38d8cbd20d9932ba948efaa364bb62651d5ad4'

这是我的代码“login.php”

<?php
//Start session
session_start();

//Connect to mysql server
include('config.php');




function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
$a = clean($_POST['username']);
$password = clean($_POST['password1']);
$passwordx= sha1($password);





//Create query
$qry="SELECT * FROM members WHERE username = '$a' AND pas= '$passwordx'";
$result=mysql_query($qry);
echo $qry;
//Check whether the query was successful or not
if($result) {
if(mysql_num_rows($result) > 0) {
//Login Successful
session_regenerate_id();
$member = mysql_fetch_assoc($result);
$_SESSION['SESS_MEMBER_ID'] = $member['id'];
$_SESSION['SESS_FIRST_NAME'] = $member['fname'];

$number=$member['number'];

if($number=='1')
{
mysql_query("UPDATE members SET number=number+1 WHERE id='".$_SESSION['SESS_MEMBER_ID'] ."' ") ;
header("location: info.php");
exit();
}
else
{
header("location: welcome.php");
exit();
}

exit();
} elseif(mysql_num_rows($result) == 0){

header("location: error.php");
exit();
}
} else {
header("location: error.php");
exit();
}
?>

有人能发现错误吗?

最佳答案

这个:echo $qry;

一旦执行此操作,您将无法使用 header() 进行重定向。

来自文档 (http://php.net/manual/en/function.header.php):

Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP.

关于php - MySQL 查询在本地主机上工作正常,但在服务器上不行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25442483/

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