mysqli_fetch无效。我正在使用000webhost和phpmyadmin。有什么建议?

时间:2017-06-01 21:31:40

标签: php mysql database image upload

这是我的代码,我收到此错误:警告:mysqli_fetch_array()要求参数1为mysqli_result,第17行的/storage/h11/920/1783920/public_html/Complete/showimage.php中给出布尔值

我不知道为什么它不起作用,任何建议都会受到赞赏,

HTML:

<!DOCTYPE html>

<html>
<body>

<form method="post" action="upload.php" enctype="multipart/form-data">

<label>Choose File to Upload:</label><br />

<input type="hidden" name="id" />

<input type="file" name="uploadimage" /><br />

<input type="submit" value="upload" />

</form>




</body>
</html>

PHP上传:

<?php
$target_Folder = "upload/";

$uid = $_POST['id'];

$target_Path = $target_Folder.basename( $_FILES['uploadimage']['name'] );

$savepath = $target_Path.basename( $_FILES['uploadimage']['name'] );

    $file_name = $_FILES['uploadimage']['name'];

    if(file_exists('upload/'.$file_name))
{
    echo "That File Already Exisit";
    }
    else
    {

$host='localhost';
$user='id1783920_123456';
$pass='';
$db='id1783920_mydb';

$con=mysqli_connect($host,$user,$pass,$db);
if($con) {
//echo 'connected successfully to id1783920_mydb database';
}

        $sql = "INSERT INTO Signup (id,image, image_name)
                    VALUES     ('','$target_Folder$file_name','$file_name') ";

        if (!mysqli_query($con,$sql))
        {
            die('Error: ' . mysqli_error($con));
        }
        echo "1 record added successfully in the database";
        echo '<br />';
        mysqli_close($con);

        // Move the file into UPLOAD folder

        move_uploaded_file( $_FILES['uploadimage']['tmp_name'],     $target_Path );

        echo "File Uploaded <br />";
        echo 'File Successfully Uploaded to:&nbsp;' . $target_Path;
        echo '<br />';  
        echo 'File Name:&nbsp;' . $_FILES['uploadimage']['name'];
        echo'<br />';
        echo 'File Type:&nbsp;' . $_FILES['uploadimage']['type'];
        echo'<br />';
        echo 'File Size:&nbsp;' . $_FILES['uploadimage']['size'];

    }
?>

<a href="showimage.php">Show Image</a>


?>

PHP Show_Image:

<?php


$host='localhost';
$user='id1783920_123456';
$pass='123456';
$db='id1783920_mydb';

$con=mysqli_connect($host,$user,$pass,$db);
if($con) {
//echo 'connected successfully to id1783920_mydb database';
}

$result = mysqli_query($con,"SELECT * FROM image " );


while($row = mysqli_fetch_array($result)) // THIS LINE NOT WORKING
{
echo '<img src="' . $row['image'] . '" width="200" />';
echo'<br /><br />';  
}


mysqli_close($con);

?>

我知道这应该已经回答了,但我确实做了其他“答案”告诉我的事情......有人可以告诉我如何将答案纳入我的代码吗?

0 个答案:

没有答案