php显示错误,即使数据已插入数据库
在Php中,我正在使用一些数据插入进行文件上传 我的表格是这样的php显示错误,即使数据已插入数据库,php,mysql,database,Php,Mysql,Database,在Php中,我正在使用一些数据插入进行文件上传 我的表格是这样的 <form id="formID1" method="post" action="'.$_SERVER['REQUEST_URI'].'" enctype="multipart/form-data"> <label for="">'.$this->l('Add Store Type').'</label> <input type="text" name="s
<form id="formID1" method="post" action="'.$_SERVER['REQUEST_URI'].'" enctype="multipart/form-data">
<label for="">'.$this->l('Add Store Type').'</label>
<input type="text" name="store_type" />
<label for="">'.$this->l('Upload Your Custom Icon').'</label>
<input type="FILE" name="custom_icon" id="custom_icon" />
<input type="submit" name="store_config" value="'.$this->l('Add Store Configuration').'" class="button" />
<form>
For uploading images I am doing a folder with 777 permission on it.
$uploaddir=dirname(__FILE__)."/storeconfig";
if(!file_exists($uploaddir)) {
mkdir($uploaddir, 777, true);
}
$tmpName=$uploaddir."/";
在这里,在点击按钮
添加存储配置
后,值成功存储到数据库中,但我仍然收到错误您有一些我在表单中设置的错误。它应该显示成功更新的设置。有人能告诉我这个错误是怎么来的吗?move\u Upload\u文件失败了,它与数据库无关。可能是权限问题。你知道为什么要添加错误检查吗?这可能是权限问题,请查看文件夹权限并告诉我们结果。不要使用mysql_*函数访问数据库。他们被弃用了。使用mysqli或PDO代替…我得到了错误。我刚刚获得了文件夹权限,它成功了。但我想知道,既然我在代码中设置了777权限,那么为什么我必须再次手动设置权限?
if(isset($_POST['store_config'])) {
global $uploaddir;
$custom_icon_name = time().$_FILES['custom_icon']['name'];
$allowed_extensions = array('gif','jpg','png');
$path_info = pathinfo($custom_icon_name);
if( !in_array($path_info['extension'], $allowed_extensions)) {
echo "Incorrent file extension, Please Use png,jpg or gif files only";
} else {
if(mysql_query('INSERT INTO `'._DB_PREFIX_.'store_config` (`store_config_id`,`store_type`,`custom_icon`) VALUES ("","'.$store_type.'","'.$custom_icon_name.'") ')) {
if(move_uploaded_file($_FILES['custom_pin']['tmp_name'],$tmpName.$custom_icon_name)) {
echo "Settings updated successfully";
} else {
echo "You Have Some Errors";
}
}
}
}