Undefined Variable

6 posts by 3 authors in: Forums > CMS Builder
Last Post: October 26, 2012   (RSS)

Im getting a lot of "NOTICE: UNDEFINED VARIABLE:" while trying to display records on a detail page of mine...
this is an example...
http://seenstream.com/detail.php?Speakeasy-Ultra-Lounge-3

I thought I have the code right, but apparently I dont. Im thinking i have something wrong here...

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php require_once "cmsAdmin/lib/viewer_functions.php"; ?>
<?php if (!@$GLOBALS['GEOCODER_PLUGIN']) { die("You must activate the Geocoder plugin before you can access this page."); } ?>
<?php

// get records
list($participating_barsRecords, $participating_barsMetaData) = getRecords(array(
'tableName' => 'participating_bars',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$record = @$participating_barsRecords[0]; // get first record

// show error message if no matching record is found
if (!$record) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;
}

?>

Re: [shawnpatoka] Undefined Variable

Hi shawnpatoka ,

The error message points to an issue on line 87 of your page.

Without seeing the actual php code it's harder to figure out exactly what's going on.

Could you attach your page code?

Thanks,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [shawnpatoka] Undefined Variable

Hi shawnpatoka,

Running out the door, but the only thing I can see off the top, (others with keener eyes may differ) is that in the participating_bars list records call you might try:

'where' => '', // load first record
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',


Best,

Jerry
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [shawnpatoka] Undefined Variable

Hi,

I think I can see the problem. I think your using the wrong variable name to try to display the items from the record. For example on line 73 you have

<?php echo htmlencode($participating_barsRecord['title']) ?>

But I think you should use:

<?php echo htmlencode($record['title']) ?>

This is because when you use getRecords it returns an array list of entries. This code on line 12 sets that first entry to a variable to make displaying them easier:

$record = @$participating_barsRecords[0]; // get first record and set it to a variable

Thanks!
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] Undefined Variable

That's why the IT folks get the big bucks.

They really understand what they're doing.

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php