Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP空白页,但每隔一页就可以工作_Php - Fatal编程技术网

PHP空白页,但每隔一页就可以工作

PHP空白页,但每隔一页就可以工作,php,Php,这是我在错误日志中得到的错误 [Wed Mar 12 15:54:04.809152 2014] [:error] [pid 6111] [client] PHP Parse error: syntax error, unexpected 'else' (T_ELSE) in /home/toolplas/public_html/main/new_incoming.php on line 354, referer: https://toolplas.com/post_file.php?job_

这是我在错误日志中得到的错误

[Wed Mar 12 15:54:04.809152 2014] [:error] [pid 6111] [client] PHP Parse error:  syntax error, unexpected 'else' (T_ELSE) in /home/toolplas/public_html/main/new_incoming.php on line 354, referer: https://toolplas.com/post_file.php?job_num=1000
这很奇怪,因为这个页面在我的开发服务器上工作

代码:


$(文档).ready(函数(){
$(“#文件夹”).html(“”);
$('文件夹').append('选择');
$.ajax({
url:'phplib/list_folder.php',
键入:“post”,
数据:{date:$('#date').val()

文件夹

抱歉,太长了。它抱怨的其他问题在文件的末尾。有人有线索吗?

您的问题在第170行:



请注意,这里有一个问题:
开发服务器上是否关闭了错误?@RUJordan根据NP++的括号高亮显示,它应该匹配
if($loggedin){
在第7行。你给我们的代码没有错误中提到的第357行。你能给我们它引用的最新文件吗?你真的应该开始使用花括号。更容易阅读和调试。你应该对所有条件的内容始终使用花括号。事实上,我强烈推荐以下php图尽可能多的使用标准,尤其是PSR-1和PSR-2()。谢谢你发现了这一点!我完全同意你的第3段。之前的开发人员实际上已经开始使用Silex重新编写应用程序的一部分,但我还没有深入研究并开始学习。最终整个应用程序都将使用该框架,因为现在它完全是一团糟。
<?php
$page = 'New Incoming Data';
$renamed = false;
$post_array = array('folder' => null);
require_once('includes/config.php');
require_once('includes/auth.php');
if($loggedin) {
require_once('includes/header.php');

if(isset($_SESSION['new'])){
   $post_json = $_SESSION['post'];
   $new_json = $_SESSION['new'];
   unset($_SESSION['post']);
   unset($_SESSION['new']);
   $post_array = jsonDecode($post_json);
   $new_files_array = json_decode($new_json);
   if($debug){
      echo '<div style="margin-left:201px"><pre>';
         print_r($new_files_array);
      echo '</pre></div>';
      echo '<div style="margin-left:201px"><pre>';
         print_r($post_array);
      echo '</pre></div>';
   }
   $renamed = true;
   $url = stripcslashes($post_array['url']);
   require_once('/home/toolplas/public_html/Twig/Autoloader.php');

   Twig_Autoloader::register();
   $loader = new Twig_Loader_String();
   $twig = new Twig_Environment($loader);
}

?>
<script type='text/javascript'>
   $(document).ready(function(){
      $('#folder').html('');
      $('#folder').append('<option>Select</option>');
      $.ajax({
         url: 'phplib/list_folder.php',
         type: 'post',
         data: { date: $('#date').val()<?php

            /*if($renamed){
               echo ", current: '" . $post_array['folder'] . "'";
            }*/

            ?> },
         dataType: 'json',
         success: function(data){
            $.each(data, function(){
               if(this === '<?php echo $post_array['folder'] ?>'){
                  $('#folder').append('<option selected="selected" value="' + this + '">' + this + '</option>');
               } else {
                  $('#folder').append('<option value="' + this + '">' + this + '</option>');
               }
            })
         }
      });
      var parts = [ <?php echo getparts($dbc3); ?> ];
      //$('.part_input').autocomplete({ source: "phplib/json_search.php?table=indata_part_type&field=name" });
      $('#program').autocomplete({ source: "phplib/json_search.php?table=view_program&field=program" });
      $('#contact').autocomplete({ source: "phplib/json_search.php?table=indata_contacts&field=name" });
      $('#source').autocomplete({ source: "phplib/json_search.php?table=data_source&field=name" });
      $('#date').change(function(){
         $('#folder').html('');
         $('#folder').append('<option>Select</option>');
         $.ajax({
            url: 'phplib/list_folder.php',
            type: 'post',
            data: {
               date: $(this).val()
            },
            dataType: 'json',
            success: function(data){
               $.each(data, function(){
                  $('#folder').append('<option value="' + this + '">' + this + '</option>');
               })
            }
         });
      });
      $('#fetch').click(function(){
          $.ajax({
            url: "phplib/get_infiles2.php",
            type: "POST",
            data: {
                cust: $('#source').val(),
                date: $('#date').val(),
                folder: $('#folder').val(),
                intype: $('[name^=in_type]').serializeArray(),
                outtype: $('[name^=out_type]').serializeArray()
            },
            dataType: "html",
            success: function(data){
                $('#files').html(data);
            }
        });
      });
      $('.add_type').live('click',function(){
         $html = $(this).parent().html();
         $(this).parent().parent().append('<p>' + $html + '</p>');
      });
      /*$('#add_fease').live('click',function(){
         $.ajax({
            url: 'phplib/get_feases.php',
            type: 'post',
            data: {
               job_num: $('[name^=file]')
            },
            dataType: 'html',
            success: function(data){
               alert(data);
            }
         });
      });*/
      $('form').validate();
   });
</script>
<div id="content">
   <h2>New Incoming Data</h2>
   <form action='phplib/new_incoming.php' method='post'>
   <div id='indata'>
      <div id='formhead'>

         <div id='left' style='width:400px;'>
            <p>
               <label>Autogenerated Q Number</label>
               <input name='q_num' value="<?php if($renamed) echo $post_array['q_num']; else echo getnextqnum($dbc3); ?>" />
            </p>
            <p>
               <label>Data Source</label>
               <input name='source' id='source' value="<?php if($renamed) echo $post_array['source']; ?>" />
            </p>
            <p>
               <label>Date Received</label>
               <input name='date' id='date' class='datepicker' value="<?php if($renamed) echo $post_array['date']; else echo date(INPUT_DATE_FMT, strtotime('NOW')) ?>" />
            </p>
            <p>
               <label>Media</label>
               <select name='media' required>
                  <option value=''>Select</option>
                  <?php
                      $sql = "SELECT * FROM media";
                      $result = mysqli_query($dbc3, $sql);
                      while($row = mysqli_fetch_assoc($result)){
                          echo "<option";
                         if($renamed) if($post_array['media'] == $row['id']) echo " selected='selected'";
                          echo " value='" . $row['id'] . "'>" . $row['name'] . "</option>";
                      }
                  ?>
               </select>
            </p>
            <p>
               <label>Program</label>
               <input name='program' id='program' value="<?php if($renamed) echo $post_array['program']; ?>" />
            </p>
            <p>
               <label>Contact</label>

               <input name='contact' id='contact' value="<?php if($renamed) echo $post_array['contact']; ?>" />
            </p>
            <p>
               <label>Filename/PKG</label>
                    <?php if($renamed){
                  echo "<input type='text' name='folder' id='folder' readonly='readonly' value='" . $post_array['folder'] . "' />";
               } else { ?>
               <select name='folder' id='folder'>
                  <option>Select</option>
               </select>
                    <? } ?>
            </p>
         </div>
         <div id='right' style='margin-left:400px;'>
            <?php if($renamed){
               $in_type = $post_array['in_type'];
               $out_type = $post_array['out_type'];

               $intype = array();
               foreach($in_type as $key => $value){
                  $intype[] = $value['value'];
               }
               $outtype = array();
               foreach($out_type as $key => $value){
                  $outtype[] = $value['value'];
               }

               foreach($intype as $key => $value){
               ?>

               <p>
                  <label>In Type</label>
                  <select name='in_type[]'>

                     <?php
                         $sql = "SELECT * FROM datatype";
                         $result = mysqli_query($dbc3, $sql);
                         while($row = mysqli_fetch_assoc($result)){
                           echo "<option";
                             if($renamed) if($value == $row['id']) echo " selected='selected'";
                             echo " value='" . $row['id'] . "'>" . $row['name'] . "</option>";
                         }
                     ?>
                  </select>
                  <label>Out Type</label>
                  <select name='out_type[]'>

                     <?php
                         $sql = "SELECT * FROM datatype";
                         $result = mysqli_query($dbc3, $sql);
                         while($row = mysqli_fetch_assoc($result)){
                           echo "<option";
                             if($renamed){ if($outtype[$key] == $row['id']) echo " selected='selected'"; }
                             else{ if($row['name'] == 'Iges') echo " selected='selected'"; }
                             echo " value='" . $row['id'] . "'>" . $row['name'] . "</option>";
                         }
                     ?>
                  </select>
                  <a href='javascript:void()' class='add_type'>Add</a>
               </p>

               <?php }
            } else { ?><p>
               <label>In Type</label>
               <select name='in_type[]'>

                  <?php
                      $sql = "SELECT * FROM datatype";
                      $result = mysqli_query($dbc3, $sql);
                      while($row = mysqli_fetch_assoc($result)){
                        echo "<option";
                          if($renamed) if($post_array['data_type'] == $row['id']) echo " selected='selected'";
                          echo " value='" . $row['id'] . "'>" . $row['name'] . "</option>";
                      }
                  ?>
               </select>
               <label>Out Type</label>
               <select name='out_type[]'>

                  <?php
                      $sql = "SELECT * FROM datatype";
                      $result = mysqli_query($dbc3, $sql);
                      while($row = mysqli_fetch_assoc($result)){
                        echo "<option";
                          if($renamed){ if($post_array['data_type'] == $row['id']) echo " selected='selected'"; }
                          else{ if($row['name'] == 'Iges') echo " selected='selected'"; }
                          echo " value='" . $row['id'] . "'>" . $row['name'] . "</option>";
                      }
                  ?>
               </select>
               <a href='javascript:void()' class='add_type'>Add</a>
            </p>
            <?php } ?>

         </div>
         <div style='clear:both'></div>
         <input type='button' id='fetch' value='Fetch All The Things' />
      </div>
      <div id='files'>
      <?php if($renamed){ ?>
      <h2>Files</h2>
      <?php
         $indatatype = array();
   $sql = "SELECT * FROM datatype_extension";
   $result = mysqli_query($dbc3, $sql);
   while($row = mysqli_fetch_assoc($result)){
      if(in_array($row['datatype'], $intype)){
          $indatatype[] = $row['ext'];
      }
   }

   $datatype = array();
   foreach($in_type as $key => $value){
      $datatype[] = array('in' => $value['value'], 'out' => $out_type[$key]['value']);
   }
   //print_r($datatype);
   //echo $url;
   $files = array();
   if ($handle = opendir($url)) {
      $num = 0;
      while (false !== ($file = readdir($handle))) {
         if ($file != '.' && $file != '..' && $file != 'Thumbs.db' && !is_dir("$url/$file")){
            if(in_array(strtolower(pathinfo("$url/$file", PATHINFO_EXTENSION)), $indatatype)){
               foreach($intype as $key => $value){
                  if(getfileext($value) == strtolower(pathinfo("$url/$file", PATHINFO_EXTENSION))){
                     $in = $value;
                     $out = $outtype[$key];
                  }
               }
               $files[] = array('o_name' => $file, 'outtype' => $out, 'intype' => $in, 'size' => number_format(filesize("$url/$file")));
            }
         }
      }
   }

   $part_type = array();
   $sql = "SELECT * FROM indata_part_type";
   $result = mysqli_query($dbc3, $sql);
   while($row = mysqli_fetch_assoc($result)){
       $part_type[] = array('name' => $row['name'], 'id' => $row['id']);
   }

$html = <<<EOF
   <table class='fancy'>
      <thead>
         <tr>
            <th></th>
            <th>Job Number</th>
            <th>New File Name</th>
            <th>Original File Name</th>
            <th>File Size</th>
            <th>Part</th>
            <th>Part Number</th>
            <th>Description</th>
         </tr>
      </thead>
      <tbody>
         {% for item in files %}
            <tr>
               <td style='text-align:center;'><input type='checkbox' name="file[{{ loop.index }}][active]" value='YES' checked='checked' style='width:20px;'  /></td>
               <td><input style='width:100%;' name="file[{{ loop.index }}][job_num]" value='{{ item.job_num }}' /></td>
               <td><input style='width:100%;' class='unique' name="file[{{ loop.index }}][n_file]" value='{{ item.n_file }}' /></td>
               <td>{{ item.o_file }}<input type='hidden' name="file[{{ loop.index }}][o_file]" readonly='readonly' value='{{ item.o_file }}' /></td>
               <td>{{ item.size }}<input type='hidden' name="file[{{ loop.index }}][size]" readonly='readonly' value='{{ item.size }}' /></td>
               <td><select name="file[{{ loop.index }}][part]">
                  <option value=''>Select</option>
                  {% for part in parts %}
                  <option value='{{ part.id }}'{% if item.part == part.id %} selected='selected'{% endif %}>{{ part.name }}</option>
                  {% endfor %}
               </select></td>
               <td><input style='width:100%;' name="file[{{ loop.index }}][part_num]" value='{{ item.part_num }}' /></td>
               <td><input style='width:100%;' name="file[{{ loop.index }}][desc]" value='{{ item.desc }}' /></td>
               <input type='hidden' name='file[{{ loop.index }}][outext]' value='{{ item.outext }}' />
               <input type='hidden' name='file[{{ loop.index }}][inext]' value='{{ item.inext }}' />
               <input type='hidden' name='file[{{ loop.index }}][version]' value='{{ item.version }}' />
            </tr>
         {% endfor %}
      </tbody>
   </table>
   <input type='hidden' name='url' value='{{ url }}' /><input type='submit' name='rename' value='Rename' /> <input type='submit' name='add_fease' id='add_fease' value='Add Fease' /> <input type='submit' name='submit' id='submit' value='Submit' />
EOF;

   echo $twig->render( $html, array('files' => $new_files_array, 'parts' => $part_type, 'url' => $url) );

       } ?>
      </div>

   </div>
   </form>
</div>
<?php
  require_once('includes/footer.php');
  } else echo showlogin();
?>
                <? } ?>