Not seeing the problem

6 posts by 2 authors in: Forums > CMS Builder
Last Post: December 19, 2012   (RSS)

By Mohaukla - December 17, 2012

I'm getting an error message on the image part of my code, but I don't see the problem.

Code:

<!--first column starts--><?php foreach ($all_toursRecords as $record): ?>
<div class="span12">
<h2><a href="<?php echo $record['_link'] ?>"><?php foreach ($record['image'] as $index => $upload): ?><img src="<?php echo $upload['thumbUrlPath'] ?>" alt="<?php echo htmlencode($record['title']) ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" hspace="10" vspace="10" align="right"></a><?php endforeach ?><a href="tours_details.html" class=""><?php echo htmlencode($record['title']) ?></a></h2>
<?php echo date("D, M jS, Y", strtotime($record['start'])) ?> to <?php echo date("D, M jS, Y", strtotime($record['end'])) ?><br>
<?php echo $record['content']; ?>
<p><a href="<?php echo $record['_link'] ?>" class="color">Complete Tour Details</a></p>
<hr>
</div><?php endforeach ?>
<!--first column ends-->


Error Message:

Notice: Undefined index: image in D:\HostingSpaces\rileytours\rileytours.com\wwwroot\tours_season.php on line 226 Warning: Invalid argument supplied for foreach() in D:\HostingSpaces\rileytours\rileytours.com\wwwroot\tours_season.php on line 226 Yellowstone Winter Escape

Line 226:

<h2><a href="<?php echo $record['_link'] ?>"><?php foreach ($record['image'] as $index => $upload): ?><img src="<?php echo $upload['thumbUrlPath'] ?>" alt="<?php echo htmlencode($record['title']) ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" hspace="10" vspace="10" align="right"></a><?php endforeach ?><a href="tours_details.html" class=""><?php echo htmlencode($record['title']) ?></a></h2>


Page in question:

http://rileytours.com.r15.millsys.org/tours_season.php?season=Spring

Michael Moyers



Owner of Just Rite Design Inc. A growing network of professionals in web design, graphic design, flash development, programming, and audio & video productions.



"Due to budget constraints, the Light at the end of the tunnel will be temporarily out!"

By gregThomas - December 17, 2012

Hi,

The most likely problem is with this line:
<?php foreach ($record['image'] as $index => $upload): ?>
Is the field name for your upload field definitely image? Secondly have you uploaded any images for these entries, as CMS Builder doesn't send an image array at all if no uploads have been added which would cause the code to display the same error.

If it's neither of these problems would it be possible to post or attach the code for the entire file?

Thanks!

Greg
Greg Thomas







PHP Programmer - interactivetools.com

By Mohaukla - December 17, 2012

I did change the field to main_image and checked and all the entries have a picture uploaded.

New error message shows the change:

Notice: Undefined index: main_image in D:\HostingSpaces\rileytours\rileytours.com\wwwroot\tours_season.php on line 226 Warning: Invalid argument supplied for foreach() in D:\HostingSpaces\rileytours\rileytours.com\wwwroot\tours_season.php on line 226

Michael Moyers



Owner of Just Rite Design Inc. A growing network of professionals in web design, graphic design, flash development, programming, and audio & video productions.



"Due to budget constraints, the Light at the end of the tunnel will be temporarily out!"

By Mohaukla - December 18, 2012

Sorry Greg,
Missed the bit about the complete file ... Here it is
Michael Moyers



Owner of Just Rite Design Inc. A growing network of professionals in web design, graphic design, flash development, programming, and audio & video productions.



"Due to budget constraints, the Light at the end of the tunnel will be temporarily out!"
Attachments:

tours_season.php 12K

By gregThomas - December 18, 2012

I think I've spotted the problem. You've currently got loadUploads set to false in your getRecords function for the all_tours table, so the function isn't retrieving any of your uploaded files. If you change line 27 so that loadUploads is set to true, this should solve the problem.

list($all_toursRecords, $all_toursMetaData) = getRecords(array(
'tableName' => 'all_tours',
'loadUploads' => true,
'allowSearch' => false,
));


Thanks

Greg
Greg Thomas







PHP Programmer - interactivetools.com