【发布时间】:2017-01-23 01:13:22
【问题描述】:
我的代码在本地主机中运行良好,但在服务器上传后我收到此错误 -> 禁止
您无权访问此服务器上的 /admin/add.php。 此外,在尝试使用 ErrorDocument 处理请求时遇到 404 Not Found 错误。
对其进行了搜索,但在 fb grps 中也没有找到合适的解决方案。还有一件事,根文件夹中没有 .htaccess 文件。尝试在服务器中添加 .htaccess 文件,但效果不佳。我在 textarea 中使用 Summernote,之前我使用的是 tinymce,但得到了同样的错误。没有summernote/tinymce,它的工作正常。 textarea 类型为 mediumtext
添加.php
<?php
include_once('../includes/config.php');
//if form has been submitted process it
if(isset($_POST['submit'])){
$_POST = array_map( 'stripslashes', $_POST );
//collect form data
extract($_POST);
//very basic validation
if($category_id ==''){
$error[] = 'Please select the category id.';
}
if($cam_unique_id ==''){
$error[] = 'Please enter the cam unique id.';
}
if($cam_features ==''){
$error[] = 'Please enter cam feature.';
}
if(!isset($error)){
try {
//insert into database
$stmt = $db->prepare('INSERT INTO cam_details (category_id,subcategory_id,cam_unique_id,cam_name,brand,cam_features,cam_spec_t1,cam_spec_t2,cam_spec_t3,cam_spec_t4,cam_spec_t5,cam_spec_t6,cam_spec1,cam_spec2,cam_spec3,cam_spec4,cam_spec5,cam_spec6) VALUES
(:category_id, :subcategory_id, :cam_unique_id, :cam_name, :brand, :cam_features, :cam_spec_t1, :cam_spec_t2, :cam_spec_t3, :cam_spec_t4, :cam_spec_t5, :cam_spec_t6,:cam_spec1, :cam_spec2, :cam_spec3, :cam_spec4, :cam_spec5, :cam_spec6)') ;
$stmt->execute(array(
':category_id' => $category_id,
':subcategory_id' => $subcategory_id,
':cam_unique_id' => $cam_unique_id,
':cam_name' => $cam_name,
':brand' => $brand,
':cam_features' => $cam_features,
':cam_spec_t1' => $cam_spec_t1,
':cam_spec_t2' => $cam_spec_t2,
':cam_spec_t3' => $cam_spec_t3,
':cam_spec_t4' => $cam_spec_t4,
':cam_spec_t5' => $cam_spec_t5,
':cam_spec_t6' => $cam_spec_t6,
':cam_spec1' => $cam_spec1,
':cam_spec2' => $cam_spec2,
':cam_spec3' => $cam_spec3,
':cam_spec4' => $cam_spec4,
':cam_spec5' => $cam_spec5,
':cam_spec6' => $cam_spec6
));
//redirect to index page
header('Location: index.php');
exit;
} catch(PDOException $e) {
echo $e->getMessage();
}
}
}
//check for any errors
if(isset($error)){
foreach($error as $error){
echo '<p class="error">'.$error.'</p>';
}
}
?>
【问题讨论】:
-
您是否检查了服务器中文件和文件夹的文件/文件夹权限?
-
问主人...
-
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.仅表示您没有设置 403 的错误文档,可以忽略。检查网络服务器错误日志,但很可能是权限错误。 -
授予 777 权限 add.php 仍然出现错误@Devon
-
@IamSrkfan,你检查服务器日志了吗?仅仅因为您在 add.php 上有 777 并不意味着该目录可以被 Web 服务器读取或不存在其他错误。
标签: php mysql summernote