急求代码修改
时间:2011-10-21
来源:互联网
<?php
$query="select tpmc from tb_tpsc order by id desc";
$res = mysql_query($query);
while($result = mysql_fetch_array($res)){
echo " <img src='uploadimg/<?php echo $result['tpmc']?> '/>" ;
}
?>
运行后错误提示是 Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in D:\AppServ\www\xy\sss.php on line 15
要怎么解决????
最后一行用$filename替换$result['tpmc'],运行后是图片不会显示,只有一些×
求高手指点
作者: dlx1014 发布时间: 2011-10-21
作者: jordan102 发布时间: 2011-10-21
改为
echo " <img src='uploadimg/$result[tpmc]'/>" ;
显示XX说明图片地址不正确.
作者: ZT_King 发布时间: 2011-10-21
PHP code
echo " <img src='uploadimg/".$result['tpmc']."'/>" ;
作者: ohmygirl 发布时间: 2011-10-21
echo " <img src='uploadimg/<?php echo $result['tpmc']?> '/>" ;
改为
echo " <img src='uploadimg/$result[tpmc]'/>" ;
显示XX说明图片地址不正确.
我写成绝对路径之后 运行显示的是图片图标
作者: dlx1014 发布时间: 2011-10-21
引用 2 楼 zt_king 的回复:
echo " <img src='uploadimg/<?php echo $result['tpmc']?> '/>" ;
改为
echo " <img src='uploadimg/$result[tpmc]'/>" ;
显示XX说明图片地址不正确.
我写成绝对路径之后 运行显示的是图片图标
图片是什么,显示就是什么,什么叫显示的图片图标。
作者: ohmygirl 发布时间: 2011-10-21
echo " <img src='uploadimg/".$result['tpmc']."'/>" ;
前一个问题谢谢哦,解决了
现在的这个问题和那个也类似,我就是不会
我又在表单中添加的一个列表“达人收藏”和“明星非常态”,想把选择的二者之一写入数据表tb_tpsc的type字段中,在insert语句中要怎样写代码?
<form enctype="multipart/form-data" method="post" name="upform">
<label>选择图片类型
<select name="lstCount" id="lstCount" onchange="setCount();">
<option value="varchar"[selectd="selected"]>达人收藏</option>
<option value="varchar"[selectd="selected"]>明星非常态</option>
</select>
</label> <br> <br>
上传文件:
<input name="upfile" type="file">
<br>
允许上传的文件类型为:<?=implode(', ',$uptypes)?>
<br>
上传者:
<input name="upauthor" type="author">
<br>
<input type="submit" value="上传">
</form>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if (!is_uploaded_file($_FILES["upfile"][tmp_name]))
//是否存在文件
{
echo "图片不存在!";
exit;
}
$file = $_FILES["upfile"];
if($max_file_size < $file["size"])
//检查文件大小
{
echo "文件太大!";
exit;
}
if(!in_array($file["type"], $uptypes))
//检查文件类型
{
echo "文件类型不符!".$file["type"];
exit;
}
if(!file_exists($destination_folder))
{
mkdir($destination_folder);
}
$filename=$file["tmp_name"];
$image_size = getimagesize($filename);
$pinfo=pathinfo($file["name"]);
$ftype=$pinfo['extension'];
$destination = $destination_folder.time().".".$ftype;
if (file_exists($destination) && $overwrite != true)
{
echo "同名文件已经存在了";
exit;
}
if(!move_uploaded_file ($filename, $destination))
{
echo "移动文件出错";
exit;
}
$sql="insert into tb_tpsc (id,tpmc,scsj,author,type)values('','$destination',now(),'{$_POST[upauthor]}')";
mysql_query($sql);//导入数据库
echo " <font color=red>已经成功上传</font><br>文件名: <font color=blue>".$destination_folder.$fname."</font><br>";
echo "上传者:".$_POST[upauthor];
echo "<br/>";
echo " 宽度:".$image_size[0];
echo " 长度:".$image_size[1];
echo "<br> 大小:".$file["size"]." bytes";
if($imgpreview==1)
{
echo "<br>图片预览:<br>";
echo "<img src=\"".$destination."\" width=".($image_size[0]*$imgpreviewsize)." height=".($image_size[1]*$imgpreviewsize);
echo " alt=\"图片预览:\r文件名:".$destination."\r上传时间:\">";
}
}
?>
作者: dlx1014 发布时间: 2011-10-21
引用 4 楼 dlx1014 的回复:
引用 2 楼 zt_king 的回复:
echo " <img src='uploadimg/<?php echo $result['tpmc']?> '/>" ;
改为
echo " <img src='uploadimg/$result[tpmc]'/>" ;
显示XX说明图片地址不正确.
我写成绝对路径之后 运行显示的是图片图标
……
显示的就是这样
作者: dlx1014 发布时间: 2011-10-21
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28