dqsvf28682 2011-07-12 17:53
浏览 38

PHP图库上传器

I've had a look at all the similar topics to this- My question is specific to a specific set of code.

Not a genius with php or mysql, quite the opposite. So I am using a tutorial to build an automated gallery with an upload system.

The code threw out all sorts of errors, mostly to do with heredoc syntax's. I fixed most of them- but I'm stuck with one on line 56.

I'll repeat it afterwards, as I can't get <ol> to work with <code>

<?php    
  include 'config.inc.php';  
  // initialization    
  $photo_upload_fields = '';    
  $counter = 1;    

  // If we want more fields, then use, preupload.php?number_of_fields=20    
  $number_of_fields = (isset($_GET['number_of_fields'])) ?    
    (int)($_GET['number_of_fields']) : 5;    
  // Firstly Lets build the Category List    
  $result = mysql_query('SELECT category_id,category_name FROM gallery_category');
  while($row = mysql_fetch_array($result)) { 
  $photo_category_list .= <<<__HTML_END
  <option value="$row[0]">$row[1]</option>

  __HTML_END;    
  }    
  mysql_free_result( $result );  
  // Lets build the Image Uploading fields    
  while($counter <= $number_of_fields) {
      $photo_upload_fields .=
      <<<__HTML_END
      <tr><td>    
  Photo {$counter}:    
  <input name="photo_filename[]"    
type="file" />    
</td></tr>    
<tr><td>    
  Caption:    
  <textarea name="photo_caption[]" cols="30"    
    rows="1"></textarea>    
</td></tr>    
__HTML_END;    
    $counter++;    
  }    

  // Final Output
  echo
  <<<__HTML_END    
<html>    
<head>    
<title>Lets upload Photos</title>    
</head>    
<body>    
<form enctype="multipart/form-data"    
  action="upload.php" method="post"    
  name="upload_form">    
  <table width="90%" border="0"    
    align="center" style="width: 90%;">    
    <tr><td>    
      Select Category    
      <select name="category">    
      $photo_category_list    
      </select>   
    </td></tr>

    $photo_upload_fields .
    <tr><td>    
      <input type="submit" name="submit"    
        value="Add Photos" />    
    </td></tr>    
  </table>    
</form>    
</body>    
</html>
__HTML_END;    
?>  

It's the $photo_upload_fields . part about 10 lines from the bottom.

Let me know if You need more detail.

Thanks in advance

  • 写回答

1条回答 默认 最新

  • douzhi8244 2011-07-12 18:00
    关注

    Change it to

      $photo_upload_fields .= <<<__HTML_END
    

    instead. The heredoc operator (<<<) binds tighter to the blank space than it does the .= on the previous line, so it's treated as a syntax error.

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大