Undefined index error

2 posts by 2 authors in: Forums > CMS Builder
Last Post: September 7, 2011   (RSS)

Hello -

Could you please help me find out why this error is occurring:

Notice: Undefined index: pdf_brochure in /usr/www/users/brother/search_details_new_canaan.php on line 102 Warning: Invalid argument supplied for foreach() in /usr/www/users/brother/search_details_new_canaan.php on line 102

The correct CMSB record is being accessed, but the inner foreach won't work...The code is directly from the CMSB code generator...Here's the code:

<?php
// determine if this listing id is in cmsb to retrieve title & body copy
// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/usr/www/users/brother/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records
list($properties_for_saleRecords, $properties_for_saleMetaData) = getRecords(array(
'tableName' => 'properties_for_sale',
'loadUploads' => '0',
'allowSearch' => '0',
'where' => 'mls_number=\''.$listing_id.'\'',
));
?>

<?php foreach ($properties_for_saleRecords as $record): ?>
<?php $mls_number = $record['mls_number']; ?>
<?php $title = $record['title']; ?>
<?php $bodycopy = $record['body_copy']; ?>

<?php foreach ($record['pdf_brochure'] as $upload): ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>
<?php endforeach ?>

<?php endforeach ?>



Thanks, Rick