Need help with an error!

Parse error: syntax error, unexpected $end in /home/sfprojects/jobeet/apps/frontend/modules/job/templates/indexSuccess.php on line 32

[php]

<?php foreach ($category->getActiveJobs(sfConfig::get('app_max_jobs_on_homepage')) as $i => $job): ?> <?php use_stylesheet('jobs.css') ?>
<?php foreach ($categories as $category): ?>

<?php echo $category ?>

  <table class="jobs">
    <?php foreach ($category->getActiveJobs() as $i => $job): ?>
      <tr class="<?php echo fmod($i, 2) ? 'even' : 'odd' ?>">
        <td class="location">
          <?php echo $job->getLocation() ?>
        </td>
        <td class="position">
          <?php echo link_to($job->getPosition(), 'job_show_user', $job) ?>
        </td>
        <td class="company">
          <?php echo $job->getCompany() ?>
        </td>
      </tr>
    <?php endforeach; ?>
  </table>
</div>
<?php endforeach; ?>
[/php]

I’ve looked up this error and so far everything I’ve read about it hasn’t been able to help me at all. Please someone help I’m still learning! F.Y.I. the final line of this block of code is line 31, yet it is telling me there is an error on line 32. I did manage to find out where the problem is. It’s in this line of text:[php]<?php foreach ($category->getActiveJobs(sfConfig::get('app_max_jobs_on_homepage')) as $i => $job): ?>[/php] because when I remove it everything seems to work ok. But I’m being told I need this line and that it should work.

jackc321

It looks like you are missing an instance of <?php endforeach; ?> somewhere.

If I were to guess, I would say on the blank line (line 13) in your posted code.

Let me know if this doesn’t help and I’ll look at it further.

Jay

Just tried that and it’s come out with Notice: Undefined variable: category on line 2. Fatal error: Call to a member function getActiveJobs() on a non-object on line 2.

Managed to solve the problem myself! Did it like this:

[php]<?php use_stylesheet('jobs.css') ?>

<?php foreach ($categories as $category): ?>

<?php echo $category ?>

  <table class="jobs">
    <?php foreach ($category->getActiveJobs(sfConfig::get('app_max_jobs_on_homepage')) as $i => $job): ?>
      <tr class="<?php echo fmod($i, 2) ? 'even' : 'odd' ?>">
        <td class="location">
          <?php echo $job->getLocation() ?>
        </td>
        <td class="position">
          <?php echo link_to($job->getPosition(), 'job_show_user', $job) ?>
        </td>
        <td class="company">
          <?php echo $job->getCompany() ?>
        </td>
      </tr>
    <?php endforeach; ?>
  </table>
</div>
<?php endforeach; ?>
[/php]

Everything works fine now, thanks for taking the time to look at this anyway :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service