我的图片保存在文件夹uploadimg中,图片的id 名称  上传作者  添加时间都在数据库中有显示  我用下面的代码显示图片
<?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'],运行后是图片不会显示,只有一些×
求高手指点

解决方案 »

  1.   

    echo " <img src='uploadimg/".$result['tpmc']."'/>" ;
      

  2.   

    echo " <img src='uploadimg/<?php echo $result['tpmc']?> '/>" ;
    改为
    echo " <img src='uploadimg/$result[tpmc]'/>" ;
    显示XX说明图片地址不正确.
      

  3.   

    我去,有你这么嵌套的么?
    echo " <img src='uploadimg/".$result['tpmc']."'/>" ;
      

  4.   


    前一个问题谢谢哦,解决了
    现在的这个问题和那个也类似,我就是不会我又在表单中添加的一个列表“达人收藏”和“明星非常态”,想把选择的二者之一写入数据表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上传时间:\">";
        }
    }
    ?>