gpt4 book ai didi

php - 从5.2.17升级到5.4.24版本后,PHP中的异常

转载 作者:行者123 更新时间:2023-12-03 08:57:01 25 4
gpt4 key购买 nike

嘿stackoverflow成员,

我已经为此苦苦挣扎了好几天,似乎无法弄清楚。

我的问题:

PHP Notice: Undefined index: use_default in settings.php on line 111

那就是抛出的错误/异常,但是在尝试修复此错误之后,我只是无法使其完全正常运行。我最近才从5.2.17升级到php中的5.4.24版本,这必须是向我抛出此错误的原因。使用较旧的php版本时,永远不会出现此异常。

无论如何,这就是我的settings.php中第111行的内容:

if (isset($_FILES['myfile']) && !empty($_FILES['myfile']['name']) && $_POST['use_default'] != 'on') {

整个部分( 更新了):
 if(empty($errors) === true) {

if (isset($_FILES['myfile']) && !empty($_FILES['myfile']['name']) && $_POST['use_default'] != 'on') {

$newpath = $general->file_newpath($path, $name);

move_uploaded_file($tmp_name, $newpath);

} else if(isset($_POST['use_default']) && $_POST['use_default'] === 'on') {
$newpath = 'avatars/default_avatar_mc.png';
}

$clan_tag = htmlentities(trim($_POST['clan_tag']), ENT_QUOTES, "UTF-8"); // ENT_QUOTES - (review, may need revised)
$gamer_tag = htmlentities(trim($_POST['gamer_tag']), ENT_QUOTES, "UTF-8"); // ENT_QUOTES - (review, may need revised)
$gender = htmlentities(trim($_POST['gender']));
$day = htmlentities(trim($_POST['day']));
$month = htmlentities(trim($_POST['month']));
$year = htmlentities(trim($_POST['year']));
$country = htmlentities(trim($_POST['country']));
$occupation = htmlentities(stripslashes($_POST['occupation']));
$interests = htmlentities(stripslashes($_POST['interests']));
$bio = htmlentities(stripslashes($_POST['bio']));
$status = htmlentities(stripslashes($_POST['status']));
$xfire = htmlentities(trim($_POST['xfire']));
$steam = htmlentities(trim($_POST['steam']));
$image_location = htmlentities(trim($newpath));

$users->update_user( $clan_tag,
$gamer_tag,
$gender,
$day,
$month,
$year,
$country,
$occupation,
$interests,
$bio,
$status,
$xfire,
$steam,
$image_location,
$user_id);
header('Location: settings.php?success');
exit();

} else if (empty($errors) === false) {
echo '<p>' . implode('</p><p>', $errors) . '</p>';
}

最后一点:
<input type="checkbox" name="use_default" id="use_default" /> <label for="use_default">Use default picture</label>

如果用户上传新图片,我只会收到此异常错误,我们将不胜感激任何帮助...

最佳答案

在执行此行之前

if (isset($_FILES['myfile']) && !empty($_FILES['myfile']['name']) && $_POST['use_default'] != 'on') {

像这样在 isset上执行 use_default
if(isset($_POST['use_default']))
{
if (isset($_FILES['myfile']) && !empty($_FILES['myfile']['name']) && $_POST['use_default'] != 'on') {

关于php - 从5.2.17升级到5.4.24版本后,PHP中的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21429509/

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