0
嘿同胞stackoverflow成員從5.2.17升級到版本5.4.24後PHP的例外
我一直在掙扎着這幾天,似乎無法弄清楚這一點。
我的問題:
PHP Notice: Undefined index: use_default in settings.php on line 111
這是錯誤/異常是在我被拋出,但在解決這個做幾次嘗試後,我根本無法得到它的工作充分。我剛剛從5.2.17升級到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>
如果用戶上傳一個NE,我只收到此異常錯誤w^PIC, - 任何幫助將不勝感激......
不幸的是沒有工作 - 只是拋出了其他例外。如果有幫助,我繼續更新「整個部分」... – user2732875
您需要添加我之前建議的if(empty($ errors)=== true){'並且不要忘記關閉大括號正確。 –