What's wrong?

9 posts by 3 authors in: Forums > CMS Builder
Last Post: April 5, 2011   (RSS)

By Toledoh - April 3, 2011

Can anyone tell me why this works;
<div id="showcase" class="showcase">
<?php foreach ($home_pageRecord['slides'] as $upload): ?>
<div>
<img src="<?php echo $upload['urlPath'] ?>" width="960" height="400"/>
<div class="showcase-caption">
<?php echo $upload['info1'] ?>
</div>
</div>
<?php endforeach ?>
</div>


yet this stops the page loading?
<div id="showcase" class="showcase">
<?php foreach ($home_pageRecord['slides'] as $upload): ?>
<div>
<img src="<?php echo $upload['urlPath'] ?>" width="960" height="400"/>
<?php if ($upload['info1']): ?>
<div class="showcase-caption">
<?php echo $upload['info1'] ?>
</div>
<? endif ?>
</div>
<?php endforeach ?>
</div>


I'm trying to only show the captions div if a caption (info1) has been entered...
Cheers,

Tim (toledoh.com.au)

Re: [Toledoh] What's wrong?

By Jason - April 4, 2011

Hi Tim,

I don't see any obvious problem with the code. Does the page page seems to stop when it reaches an upload that has a caption, or one that hasn't? Does this code actually produce an error? Sometimes, errors don't display on the screen and you need to view the page source to see them.

If you could attach a copy of your .php file and send a link to a page where this is not working, we can take a closer look at this. If you don't want to post a link in the forum, you can email it directly to support@interactivetools.com

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] What's wrong?

By Toledoh - April 4, 2011

Hi Jason.

Have a look at the attached - live at;
http://www.smcelc.com.au/web/index.php
http://www.smcelc.com.au/web/index2.php

Thanks for your help!
Cheers,

Tim (toledoh.com.au)
Attachments:

index_036.php 4K

index2_002.php 4K

Re: [Toledoh] What's wrong?

By Jason - April 4, 2011

Hi Tim,

That's a strange one. There are no syntax errors. My best guess is that something happens with your script when the showcase-caption div is missing. You can test this theory by removing the caption code all together and see if you get the same problem.

You could try replacing it with this:

<div class="showcase-caption">
<?php if ($upload['info1']): ?>
<?php echo $upload['info1'] ?>
<? endif ?>
</div>


But this would actually be the same was your original code.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] What's wrong?

By Toledoh - April 4, 2011

Hi Jason.

Have a look at the attached... they are straight out of the generator - test 3 doesn't work, which is the one with the if statements.

http://www.smcelc.com.au/web/test1.php
http://www.smcelc.com.au/web/test2.php
http://www.smcelc.com.au/web/test3.php

strange!
Cheers,

Tim (toledoh.com.au)
Attachments:

test1.php 4K

test2_001.php 4K

test3.php 5K

Re: [zip222] What's wrong?

By Toledoh - April 4, 2011

Duh!

Sometimes I think I should pack my bags... this is one of those instance.

Thanks! Everything working fine...
Cheers,

Tim (toledoh.com.au)

Re: [Toledoh] What's wrong?

By zip222 - April 4, 2011

Done it myself a million times. Glad it worked out.

Re: [zip222] What's wrong?

By Jason - April 5, 2011

Hi,

Nice catch zip! That would do it. :)
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/