当前位置: 首页 > 知识库问答 >
问题:

分析错误:语法错误,意外的$end-line 91

苏弘盛
2023-03-14

我寻找答案,发现缺少引号或括号会导致这个错误。我检查了几次,并添加了丢失的引号,但第91行在底部,所以我无法找出它,除非它是“< code>else:”我从上到下看了看,但我不确定哪个会导致错误。请借给我你的眼睛找到问题。谢谢你

<?php

if( ereg( '/[a-z-]+/[a-z]/$', $_SERVER['REQUEST_URI'])) {

$url_array = explode('/', $_SERVER['REQUEST_URI']); 
$alpha = $url_array[sizeof($url_array)-2];

$postids = $wpdb->get_col("
    SELECT p.ID
    FROM $wpdb->posts p
    WHERE p.post_title REGEXP '^" . $wpdb->escape($alpha) . "'
    AND p.post_status = 'publish' 
    AND p.post_type = 'book'
    AND p.post_date < NOW()
    ORDER BY p.post_title ASC"
);


if ($postids) {
  $args=array(
    'post__in' => $postids,
    'post_type' => 'list', 
    'post_status' => 'publish',
    'posts_per_page' => -1,
    'caller_get_posts'=> 1
  );
  $my_query = null;
  $my_query = new WP_Query($args);
  if( $my_query->have_posts() ) {

    while ($my_query->have_posts()) : $my_query->the_post(); ?>

    <div class="listing">

       <h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
        <?php the_excerpt(); ?>             
    </div>

      <?php
    endwhile;
    }

  }

}
 else {
    query_posts(array('post_type'=>'list')); 

    if (have_posts()) : while (have_posts()) : the_post(); 

     ?>          

    <div class="listing">
     <h3><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a> </h3>
    <?php the_excerpt(); ?>             
    </div>

    <?php endwhile; else:?>

    <p>Sorry, no profiles matched your criteria.</p>

   <?php  endif; ?>
</div>

<?php get_sidebar(); ?>

</div>
<?php get_footer(); ?>

共有1个答案

平庆
2023-03-14
 ...
  else {
    query_posts(array('post_type'=>'list')); 

    if (have_posts()) : while (have_posts()) : the_post(); 

     ?>          

你还没有结束那个 else {,这将引发该错误。

将其更改为:

else {
    query_posts(array('post_type'=>'list')); 

    if (have_posts()) : while (have_posts()) : the_post(); 

 ?>          

<div class="listing">
 <h3><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a> </h3>
<?php the_excerpt(); ?>             
</div>

<?php endwhile; else:?>

<p>Sorry, no profiles matched your criteria.</p>
 类似资料: