gpt4 book ai didi

PHP 和 MySQL 插入错误 : ucp is currently unable to handle this request

转载 作者:行者123 更新时间:2023-11-29 18:24:55 24 4
gpt4 key购买 nike

今天我完成了标记工作并开始编写代码,我编写了这个简单的注册代码,但是当用户单击提交按钮时,他们看到错误:

This page isn’t working
ucp.ls-rp.ge is currently unable to handle this request.
HTTP ERROR 500

如何解决这个问题?任何形式的帮助将不胜感激,并提前感谢您。

<?
$host = 'localhost';
$user = 'lsrpge14_forum';
$pass = 'lsrpgeforum123.';
$db = 'lsrpge14_forum';
$mysqli = new mysqli($host,$user,$pass,$db) or die($mysqli->error);
/* CREATE CHARACTER FUNCTIONS */
$sex = 0;

function IsRPName($name, $max_underscores = 1)
{
$underscores = 0;
if ($name[0] < 'A' || $name[0] > 'Z') return false;
for($i = 1; $i < strlen($name); $i++)
{
if($name[$i] != '_' && ($name[$i] < 'A' || $name[$i] > 'Z') && ($name[$i] < 'a' || $name[$i] > 'z')) return false;
if( ($name[$i] >= 'A' && $name[$i] <= 'Z') && ($name[$i - 1] != '_') ) return false;
if($name[$i] == '_')
{
$underscores++;
if($underscores > $max_underscores || $i == strlen($name)) return false;
if($name[$i + 1] < 'A' || $name[$i + 1] > 'Z') return false;
}
}
if ($underscores == 0) return false;
return true;
}
function SendCharacterAplication($ownerid, $name, $sex, $explainmg, $explainpg, $charbio)
{
$sql = "INSERT INTO Aplicants (ownerid, charname, sex explainmg, explainpg, charbio) " . "VALUES ('$ownerid', '$name', '$sex', '$explainmg', '$explainpg', '$charbio')";
if ($mysqli->query($sql) ){
$_SESSION['createcharerror'] = "<h2 style='color:green'>თქვენი პერსონაჟი წარმატებით შეიქმნა! დაელოდეთ ადმინისტრაციის პასუხს!</h2>";
header("location: profile.php");

}

header("location: index.php");
}

/* CREATE CHARACTER CHECK VALUES */

if ( $_SESSION['logged_in'] != 1 ) {
$_SESSION['createcharerror'] = "<h2 style='color:red'>პროფილის სანახავად გაიარეთ ავტორიზაცია!</h2>";
header("location: index.php");
}

if ( $_SESSION['countchars'] == 2)
{
$_SESSION['createcharerror'] = "<h2 style:'color:red'>თქვენ უკვე გაქვთ გაკეთებული 2 პერსონაჟი!</h2>";
header("location: index.php");
}

if(is_null($_POST['charname']))
{
$_SESSION['createcharerror'] = "<h2 style:'color:red'>ჩაწერეთ პერსონაჟის სახელი!</h2>";
header("location: index.php");
}

if(!IsRPName($_POST['charname']))
{
$_SESSION['createcharerror'] = "<h2 style='color:red;'>პერსონაჟის ნიკი არ არის სწორ ფორმატში Firstname_Lastname!</h2>";
header("location: index.php");
}

if(is_null($_POST['gender']))
{
$_SESSION['createcharerror'] = "<h2 style='color:red;'>მონიშნეთ პერსონაჟის სქესი!</h2>";
header("location: index.php");
}

if($_POST['gender'] == 'male')
{
$sex = 1;
}
else
{
$sex = 2;
}

if(str_word_count($_POST['charbio']) < 70)
{
$_SESSION['createcharerror'] = "<h2 style='color:red'>პერსონაჟის ბიოგრაფია არ უნდა იყოს 70 სიტყვა-ზე ნაკლები!</h2>";
header("location: index.php");
}
else{
SendCharacterAplication($_SESSION['masterid'], $_POST['charname'], $sex, $_POST['explainmg'], $_POST['explainpg'], $_POST['charbio']);
}

最佳答案

您可能会收到 500 错误,因为服务器配置为抑制 SQL 错误。如果您查看错误日志或输出正在运行的 SQL 并手动运行它,您可能能够看到确切的错误。

您必须清理从用户输入传递到 SQL 的任何值,在任何这些字段中使用撇号都将导致 SQL 错误(或更糟糕的 SQL 注入(inject))。

http://php.net/manual/en/mysqli.real-escape-string.php

与数据库中的表名相比,您也可能得到了错误的表名;申请人应有 2 个 p

关于PHP 和 MySQL 插入错误 : ucp is currently unable to handle this request,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46277838/

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