我想在我的图片div中显示一张图片。我编码如下。
<div id="picture">
<?php
@session_start();
$email=$_SESSION['email'];
include "db.php";
$query2=mysql_query("select profilepicture from registration where email='$email'");
if(mysql_num_rows($query2)>0)
{
while($rowtwo = mysql_fetch_array($query2))
{
echo '<img src="'.$rowtwo["profilepicture"].'" style="height:180px" />';
}
}
?>
</div>
以下给出的是我在数据库中上传图片的代码和名为uploads的文件夹
<?php
if(isset($_POST['save']))
{
$changefname=$_POST['changefname'];
$changelname=$_POST['changelname'];
$changeprofilepic=$_FILES['file']['name'];
$tmp_name=$_FILES['file']['tmp_name'];
if(!empty($changefname)&&!empty($changelname)&&!empty($changeprofilepic))
{
$location='uploads/';
if(move_uploaded_file($tmp_name, $location.$changeprofilepic))
{
//echo "uploaded";
session_start();
$email=$_SESSION['email'];
include "db.php";
$query=mysql_query("update registration set fname='$changefname', lname='$changelname', profilepicture='$changeprofilepic' where email='$email'");
header('location:homepage.php');
}
}
}
?>
当我点击“保存”按钮时,它不会显示完整的图片,而是显示一个小图标。 请帮帮我
答案 0 :(得分:0)
作为一般规则 session_start(); 应该在PHP输出任何内容之前位于代码的开头,然后您不需要@来禁止错误消息!