【问题标题】:Strict standards: Only variables should be passed [duplicate]严格标准:只应传递变量[重复]
【发布时间】:2014-06-03 16:25:06
【问题描述】:

我有显示这一点的图像上传脚本(严格标准:只有变量应该在第 33 行的 C:\wamp\www\Fcomail-Final\cpanel\fcomail\Gallery.php 中通过引用传递 调用堆栈)错误第 33 行是

require('../conn/include.php');
require('quick.php');
$query="SELECT * FROM category";
$result=mysql_query($query);
$project=$_POST['project'];
$alttext=$_POST['alttext'];
$relation=$_POST['Section'];;

if(isset($_FILES['image'])) {
    $errors=array();
    $allowed_ext=array('jpg','png','jpeg','JPG');
    $filename=$_FILES['image']['name'];
    $name=stripslashes($filename);
    **Line 33** $type=strtolower(end(explode('.',$filename)));
    $size=$_FILES['image']['size'];
    $file_tmp=$_FILES['image']['tmp_name'];
if(in_array($type,$allowed_ext) ===false) {
    $errors[]= "<span class=\"notification n-error\">Extenstion Not Allowed</span>";
}if($size > 1048576) {
    $errors[]= "<span class=\"notification n-error\">File must be less then 2mb</span>";
}if(file_exists('../../images/fcomail/gallery/'.$filename)) {
   $errors[]= "<span class=\"notification n-error\">File $filname Already Exists in directory</span>";
}if(empty($errors)) {
    if(move_uploaded_file($file_tmp, '../../images/fcomail/gallery/'.$filename)) {
        $insert="Insert into `my`.gallery(name,alttext,project,relation)VALUES('$name','$alttext','$project','$relation')";
        //echo $insert;
        $que=mysql_query($insert);
    echo "<span class=\"notification n-success\">File $filname Uploaded Sucessfully</span>";
    }
}else {
    foreach($errors as $error) {
        echo $error,'<br/>';    
    }
}
}

【问题讨论】:

  • 您是否看到右侧有一列显示 RELATED?
  • 没有一个能解决我的问题,但谢谢
  • 我标记为重复的同一个问题,阅读第二条评论,转到那个链接,阅读答案,这是同一个问题

标签: php mysql


【解决方案1】:

你需要打破下面的行

$type=strtolower(end(explode('.',$filename)));

到

$fname = explode('.',$filename);
$filename = end($fname);
$type=strtolower($filename);

原因:

来自 PHP 手册中end() 的文档。

数组。这个数组是通过引用传递的,因为它是由 功能。这意味着您必须将其传递给真正的变量,而不是 函数返回一个数组,因为只有实际变量可能是 通过引用传递。

【讨论】:

    猜你喜欢
    • 2014-11-01
    • 2015-05-27
    • 2016-10-05
    • 2014-08-17
    • 1970-01-01
    • 2012-04-08
    • 2015-02-02
    • 2016-06-04
    相关资源
    最近更新 更多