为什么以下 php 脚本不显示图像。我检查了数据库连接正常,Mysql Query 也正常。
php代码:
$upload_directory = "uploaded"; //set upload directory
$getimages = mysql_query("SELECT * FROM property_step3 WHERE propertyid =
'$propertyid' AND active =1 AND uname = '$uname'");
$re2 = mysql_fetch_array($getimages)
$images = mysql_real_escape_string(htmlspecialchars(trim($re2['imgname'])));
echo '<img src="$upload_directory/$images" width="98" height="68" /></a>';
也许我错了..
我不明白为什么有些人投票给我 DOWN ??!!
更新:
<?php
$uname = $_SESSION['uname'];
$check = mysql_query("SELECT * FROM property_step1 WHERE uname = '$uname' AND active
= 1");
$num = mysql_num_rows($check);
if($num == 0)
{
echo "<h3>You didn't upload any property. Click <a href='publishadvert.php'>here</a>
to publish your property</h3>";
}
else
{
echo "<h3>You have $num published property.</h3>";
echo "<table width='1020' cellpadding='0' cellspacing='0'>";
echo "<tr>";
echo "<td class='tabletr3'><b>Property Title</b></td>";
echo "<td class='tabletr3'><b>Area</b></td>";
echo "<td class='tabletr3'><b>State</b></td>";
echo "<td class='tabletr3'><b>City</b></td>";
echo "<td class='tabletr3'><b>Country</b></td>";
echo "<td class='tabletr3'><b>Images</b></td>";
echo "<td class='tabletr3'><b>Action</b></td>";
echo "</tr>";
while($re = mysql_fetch_array($check))
{
$propertyid = (int) $re['propertyid'];
$country = mysql_real_escape_string(htmlspecialchars(trim($re['pro_country'])));
$state = mysql_real_escape_string(htmlspecialchars(trim($re['pro_state'])));
$area = mysql_real_escape_string(htmlspecialchars(trim($re['pro_area'])));
$city = mysql_real_escape_string(htmlspecialchars(trim($re['pro_city'])));
$title = mysql_real_escape_string(htmlspecialchars(trim($re['pro_title'])));
$getimages = mysql_query("SELECT * FROM property_step3 WHERE propertyid =
'$propertyid' AND active =1 AND uname = '$uname'");
$upload_directory = dirname(__file__) . '/uploaded/'; //set upload directory
while($re2 = mysql_fetch_array($getimages))
{
$images = mysql_real_escape_string(htmlspecialchars(trim($re2['imgname'])));
}
echo "<tr>";
echo "<td class='tabletr2'>$title</td>";
echo "<td class='tabletr2'>$country</td>";
echo "<td class='tabletr2'>$state</td>";
echo "<td class='tabletr2'>$city</td>";
echo "<td class='tabletr2'>$area</td>";
echo '<img src="'.$upload_directory.'/'.$images.'" width="98"
height="68" /></a>';
echo "<td class='tabletr2'><img src='uploaded/$images'
/></td>";
echo "<td class='tabletr2'><a href='editproperty.php?propertyid=$propertyid&
uname=$uname'>Edit</a> | <a href='deleteproperty.php?propertyid=$propertyid'>Delete</a>
</td>";
echo "</tr>";
}
echo "</table>";
}
?>