【问题标题】:XAMPP why is my else bug?XAMPP 为什么是我的 else 错误?
【发布时间】:2013-08-07 14:58:37
【问题描述】:

每次我加载我得到的页面

解析错误:语法错误,第 19 行 C:\xampp\htdocs\ZeroWebsite\uploadtest.php 中的意外 ')'

<html>
<head>
<title></title>
</head>
<body>

<form action="uploadtest.php" method="POST" enctype="multipart/form-data">
        <input type="file" name="image"> <input type="submit" value="Upload">
</form>
<?php
        mysql_connect("localhost","root","") or die(mysql_error());
        mysql_select_db("dataimage") or die (mysql_error());

        $file = $_FILES['image']['tmp_name']);

        if (!isset($file))
            echo "select an image";
        else // this is my line 19
        {
            $image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
            $image_name = addslashes($_FILES['image']['name']);
            $image_size = getimagesize($_FILES['image']['tmp_name']);

            if ($image_size==FALSE)
               echo "not a image.";
            else
            {
            if (!$insert = mysql_query("INSERT INTO myimage VALUES ('','@image_name','$image')"))
                echo "problem uploading image.";
                else    
                {
                    $lastid = mysql_insert_id();
                    echo "image uploaded.<p /> Your image:<p />img src=uploadtest2.php?id=lastid>";
                    }
                }
            }?>
</body>
</html>

我在 youtube 上资助这个指南我只是想让它工作请告诉我该怎么做

【问题讨论】:

    标签: php html xampp


    【解决方案1】:
    $file = $_FILES['image']['tmp_name']);
    

    必须是

    $file = $_FILES['image']['tmp_name'];
    

    【讨论】:

    • 感谢您的帮助,但我的图像没有显示在我的屏幕上,您知道为什么吗?
    【解决方案2】:

    改变

    $file = $_FILES['image']['tmp_name']);
    

    $file = $_FILES['image']['tmp_name'];
    

    一个额外的“)”是他们的。

    【讨论】:

    • 感谢您的帮助,但我的图像没有显示在我的屏幕上,您知道为什么吗?
    【解决方案3】:

    这是$file = $_FILES['image']['tmp_name']); 的问题。删除最后一个 ) 即可。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-20
      • 2019-05-27
      • 1970-01-01
      • 2021-12-06
      • 2016-05-05
      • 2020-09-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多