Not seeing the problem
6 posts by 2 authors in: Forums > CMS Builder
Last Post: December 19, 2012 (RSS)
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
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!"
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!"
Hi,
The most likely problem is with this line:
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
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
PHP Programmer - interactivetools.com
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
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!"
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!"
Sorry Greg,
Missed the bit about the complete file ... Here it is
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!"
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!"
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.
Thanks
Greg
list($all_toursRecords, $all_toursMetaData) = getRecords(array(
'tableName' => 'all_tours',
'loadUploads' => true,
'allowSearch' => false,
));
Thanks
Greg
Greg Thomas
PHP Programmer - interactivetools.com
PHP Programmer - interactivetools.com
Thanks Greg that was the ticket.
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!"
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!"