我收到一个错误:
致命错误:常量表达式在第214行的config.php中包含无效操作
那条线是:
protected static $dbname = 'mydb_'.$appdata['id'];
Run Code Online (Sandbox Code Playgroud)
我是否在引号中出错了?或者别的地方?
我对错误消息的搜索仅显示不同的源原因(函数定义中的动态默认值).
嗨,我实际上是通过ajax将一个base64图像字符串发送到一个php脚本,它只解码字符串并将内容保存为.jpg文件.
但结果是空图像.
这怎么可能?
php脚本:
$uploadedPhotos = array('photo_1','photo_2','photo_3','photo_4');
foreach ($uploadedPhotos as $file) {
if($this->input->post('photo_1')){
$photoTemp = base64_decode($this->input->post('photo_1'));
/*Set name of the photo for show in the form*/
$this->session->set_userdata('upload_'.$file,'ant');
/*set time of the upload*/
if(!$this->session->userdata('uploading_on_datetime')){
$this->session->set_userdata('uploading_on_datetime',time());
}
$datetime_upload = $this->session->userdata('uploading_on_datetime',true);
/*create temp dir with time and user id*/
$new_dir = 'temp/user_'.$this->session->userdata('user_id',true).'_on_'.$datetime_upload.'/';
@mkdir($new_dir);
/*move uploaded file with new name*/
@file_put_contents( $new_dir.$file.'.jpg',$photoTemp);
}
Run Code Online (Sandbox Code Playgroud)
对于ajax来说没关系因为,echo $ photoTemp返回字符串.
我试过var_dump(@file_put_contents( $new_dir.$file.'.jpg',$photoTemp));,它返回,bool(true)因为图像被保存但图像中没有内容:(空图像
对于空图像,我的意思是,文件是创建和命名的,它与我传递给php的内容大小相同,但是当我尝试打开该图像进行预览时,文件无法打开,因为文件损坏或损坏类型格式
无论如何这是将照片作为base64并将其发送到php的JS:
<script type="text/javascript">
var _min_width = 470;
var _min_height = 330; …Run Code Online (Sandbox Code Playgroud) 我现在正致力于从下表中的数据中获取Json响应
通过使用以下查询:
$sql = "select * from subject where subject_name = 'maths'";
$result = mysqli_query($conn,$sql);
while($row = mysqli_fetch_array($result))
{
$data = new stdClass();
$subject_name = $row['subject_name'];
$unit = $row['unit'];
$unit_name = $row['unit_name'];
$data->subject_name=$subject_name;
$emparray[] = array('unit' => $unit,
'unit_name' => $unit_name,
);
$data->units=$emparray;
}
echo json_encode(array($data));
Run Code Online (Sandbox Code Playgroud)
我可以得到Json的回复:
现在我想要的是整体科目而不使用where子句(其中subject_name ='maths')
我需要的Json o/p如下:
我阻止了文件中的某些站点,但它们不断访问我的服务器并要求提供降低服务器速度的图像 我如何为它们添加规则,以便它们看到红色的大标志 STOP HOTLINKING
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} ^http://(www\.)?somesite\.pl [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?somesite\.pl [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?somesite\.pl [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?sklep.somesite\.eu [NC]
RewriteRule \.(gif|jpe?g|js|css)$ - [F,NC,L]
Run Code Online (Sandbox Code Playgroud)