dousong2023 2014-10-25 22:11
浏览 54

我的数据库中的图像未在我的网站上发布(PHP MySQL)

so am created a form that takes two file buttons (for images) one for the thumbnail and the other for the main image and it has successfully taken the files and placed it in the database, it has also gotten their correct directory...but i have a problem...when it time to echo the images they dont show up...some please help me

here is the form and the code(all in the same file called addimage.php):

<?php
include'includes/connect.php';

if($_POST['submit'])
 {
$img="main/";
$img= $img . basename($_FILES['photo1']['name']);

$tmb="thumb/";
$tmb= $tmb . basename($_FILES['photo2']['name']);


$imagename = mysql_real_escape_string($_POST['imagename']);
$content = mysql_real_escape_string($_POST['content']);
$links = mysql_real_escape_string($_POST['links']);
$pic1 = "main/" .(mysql_real_escape_string($_FILES['photo1']['name']));
$pic2 = "thumb/" .(mysql_real_escape_string($_FILES['photo2']['name']));

if(move_uploaded_file($_FILES['photo1']['tmp_name'], $img));{
    if(move_uploaded_file($_FILES['photo2']['tmp_name'], $tmb));{
{

    mysql_query("INSERT INTO `portweb` ( `imagename`, `content`, `links`, `photo1`, `photo2`)  VALUES('$imagename', '$content', '$links', '$pic1', '$pic2')");
    echo "files upload success";
}
}
}
/*else
{
    echo "upload failed";   
}*/

}

?>

<html>
<head>
<title>upload pictures portfolio web</title>
</head>
<body>
<a href="portweb.php">Back</a>
 <br />
 <form action="addportweb.php" method="post" enctype="multipart/form-data">
 <label>Main Image:</label>
 <input type="file" name="photo1" /><br />
<label>Thumb:</label>
<input type="file" name="photo2" /><br />
<label>Name:</label> <input type="text" name="imagename" class="text_input" maxlength="100" /><br />
<label>Description:</label>
<textarea name="content" style="width: 300px; height:80px; padding: 5px; resize:none;" ></textarea>
<br />

<label>Link:</label> <textarea name="links" style="width: 100px; height:50px; padding: 5px; resize:none;" ></textarea><br />
<input type="submit" name="submit" value="upload" /> 
</form>
</body>
</html>

and here is the function to help with the output...and also my problem:

function getportweb() {
     $query = mysql_query("SELECT * FROM portweb") or die(mysql_error());
      while($post = mysql_fetch_assoc($query)){

        echo "<img src =".$post['photo1']."/>";
            echo "<br>";

        echo "<img src =" . $post['photo2'] . "/>";
            echo"<br>";

        echo "<p>" . $post['imagename'] . "</p>";
            echo "<br>";
        echo "<p>" . $post['content'] . "</p>";
        echo "<br>";
        echo "<p>" . $post['links'] . "</p>";
            echo "<br>";

        echo "<a href=\"deleteportweb.php?id=" . $post['id'] . "\">Delete</a>";
        echo "<a href=\"editportweb.php?id=" . $post['id'] . "\">Edit</a>";
         echo "<br>";
         } 

}

i want to believe this is my problem

echo "<img src =".$post['photo1']."/>";
                echo "<br>";

            echo "<img src =" . $post['photo2'] . "/>";
                echo"<br>";

but i got nothing...please someone help

  • 写回答

1条回答 默认 最新

  • douyan1927 2014-10-25 22:22
    关注

    Try something like this:

    echo'<img src="'.$post['photo1'].'" />';    
    
    评论

报告相同问题?

悬赏问题

  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)