Login | Sign up | Toll-Free: 1-800-752-0455
 
 

Forum

 

10 posts by 3 authors in: Forums > CMS Builder
Last Post: April 1, 2014

I have added a prev next record link in a details page but there must be something with table because I get this error:

Notice: Undefined variable: blogRecord in C:\Webspace\resadmin\mmoyers\justritedesign.com\www\jrd7\single_post.php on line 22 MySQL Error: Unknown column 'date' in 'order clause' PHP Notice: Undefined variable: blogRecord in C:\Webspace\resadmin\mmoyers\justritedesign.com\www\jrd7\single_post.php on line 22

    list($blogRecords, $blogMetaData) = getRecords(array(
    'tableName'   => 'blog',
    'where'       => whereRecordNumberInUrl(0),
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  
    list($prevRecord, $nextRecord, $firstRecord, $lastRecord) = getPrevAndNextRecords(array( 
    'tableName' => 'blog', 
    'recordNum' => $blogRecord['num'], 
    'orderBy'   => 'date DESC'
  ));
  
    $blogRecord = @$blogRecords[0]; // get first record
    if (!$blogRecord) { dieWith404("Record not found!"); } // show error message if no record found
 

                           <?php if (@$prevRecord['num']): ?>
                           <a href="<?php echo (@$prevRecord['_link'])? $prevRecord['_link'] : '?' ; ?>"><i class="fa fa-angle-double-left"></i> <?php echo (@$prevRecord['_title'])? $prevRecord['_title'] : '?' ; ?></a>
                           <?php else: ?>XXXXXX<?php endif ?>
                           
                           <?php if (@$nextRecord['num']): ?>
                           <a href="<?php echo (@$nextRecord['_link'])? $nextRecord['_link'] : '?' ; ?>"><?php echo (@$nextRecord['_title'])? $nextRecord['_title'] : '?' ; ?> <i class="fa fa-angle-double-right"></i></a>
                           <?php else: ?>++++++<?php endif ?>

I am hoping that I can also swap "_link" for "_title" so that it will put the title of the the prev and next posts are. You may have to correct me there if I'm incorrect about that.

Not sure about the date column being a problem.

Thanks for any help you can give

Michael Moyers

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!"

Hi Michael,

You're getting the undefined variable error because the $blogRecord variable was declared only after you use it for getting the prev and next records. You can fix that by simply moving the "//get first record" block before the getPrevAndNextRecords block:

list($blogRecords, $blogMetaData) = getRecords(array(
  'tableName'   => 'blog',
  'where'       => whereRecordNumberInUrl(0),
  'loadUploads' => true,
  'allowSearch' => false,
  'limit'       => '1',
));

$blogRecord = @$blogRecords[0]; // get first record
if (!$blogRecord) { dieWith404("Record not found!"); } // show error message if no record found

list($prevRecord, $nextRecord, $firstRecord, $lastRecord) = getPrevAndNextRecords(array( 
  'tableName' => 'blog', 
  'recordNum' => $blogRecord['num'], 
  'orderBy'   => 'date DESC'
));

Your code for swapping the _link to _title looks good. But you might want to check your field name for the title, perhaps it should be "title" and not "_title".

Please let us know if that works for you.

Thanks,

Daryl Maximo
PHP Programmer - interactivetools.com

OK almost there.

The link to the next post works but only on the first post. So post 1 has XXXX (meaning  no previous post) and the proper title and link to the next post. Now when you click on the link for the next post the correct post shows but now both links at the bottom point back to the original post.

So I have 4 posts

Post 1 has
XXXX - Title/Link to Post 2

Post 2 has 
Title/Link to Post1 - Title/Link to Post 1

Post 3 has 
Title/Link to Post 2 - Title/Link to Post 1

Post 4 has 
Title/Link to Post 3 - Title/Link to Post 1

It is not getting the NEXT link except the first post.  

Let me know what you think.

Michael

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!"

Hi Michael,

That's very peculiar. I've been doing a bunch of tests here to try to figure this out, but I've run out of ideas. Can you provide me with your FTP information with a Second Level Support Request so I can take a closer look?

https://www.interactivetools.com/support/email_support_form.php?message=http://www.interactivetools.com/forum/forum-posts.php?Checking-Links-to-Records-in-a-Detail-Page-79391&page=1

Thanks!

All the best,
Chris

If not, can you please add 'debugSql' => true to both your getRecords() and getPrevAndNextRecords() and paste the results here?

list($blogRecords, $blogMetaData) = getRecords(array(
  'tableName'   => 'blog',
  'where'       => whereRecordNumberInUrl(0),
  'loadUploads' => true,
  'allowSearch' => false,
  'limit'       => '1',
  'debugSql'    => true,
));

$blogRecord = @$blogRecords[0]; // get first record
if (!$blogRecord) { dieWith404("Record not found!"); } // show error message if no record found

list($prevRecord, $nextRecord, $firstRecord, $lastRecord) = getPrevAndNextRecords(array( 
  'tableName' => 'blog', 
  'recordNum' => $blogRecord['num'], 
  'orderBy'   => 'date DESC',
  'debugSql'  => true,
));

Can you also post your Mysql version? You'll find this at the bottom of the Admin > General Settings page. For example, mine is:

Database Server: MySQL v5.0.37 (Max Connections: 255)

All the best,
Chris

By Mohaukla - March 31, 2014 - edited: March 31, 2014

I will send a request as well but here is the other info you asked for:

SELECT SQL_CALC_FOUND_ROWS `blog`.*
FROM `cms_blog` as `blog`
 WHERE (num = '3') 
 ORDER BY  post_date
 LIMIT 1tableName = 'blog' AND
fieldName IN ('main_image') AND
recordNum IN (3)
 ORDER BY `order`, numSELECT SQL_CALC_FOUND_ROWS `accounts`.*
FROM `cms_accounts` as `accounts`
 WHERE (`num` IN (1)) 
 ORDER BY fullname, usernameSELECT @lastSeenNum:=0, @prevNum:=0, @nextNum:=0, @firstNum:=0, @lastNum:=0, @prevNumSet:=0, @foundTarget:=0SELECT 
  IF(@firstNum, NULL, @firstNum:=num),
  @lastNum := num,
  IF(num='3', (@foundTarget:=1) AND (@prevNum:=@lastSeenNum), @lastSeenNum:=num),
  IF(@foundTarget=1 AND num !='3' AND @nextNum = 0, @nextNum := num, null)
FROM `cms_blog` 
ORDER BY  post_date  
SELECT @prevNum as 'prevRecordNum', @nextNum as 'nextRecordNum', @firstNum as 'firstRecordNum', @lastNum as 'lastRecordNum'SELECT SQL_CALC_FOUND_ROWS `blog`.*
FROM `cms_blog` as `blog`
 WHERE (num IN (2,1,1,4,0)) 
 ORDER BY  post_datetableName = 'blog' AND
fieldName IN ('main_image') AND
recordNum IN (1,2,4)
 ORDER BY `order`, numSELECT SQL_CALC_FOUND_ROWS `accounts`.*
FROM `cms_accounts` as `accounts`
 WHERE (`num` IN (1)) 
 ORDER BY fullname, username

MySQL v5.5.33 (Max Connections: 25)

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!"

Yes check FAB-339040

Damon replied to me because it had some info on a license swap. 

Michael

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!"

Thanks, Michael!

I did some tests on your server and was able to track down a mysterious bug (I think in MySQL) which seems to affect a small number of servers. I've patched the copy of CMS Builder installed on your site and getPrevAndNextRecords() is working correctly now on your single_post.php pages. Future versions of CMS Builder will contain this fix, so you'll be able to upgrade safely in the future and hopefully no one else will run into this issue! :)

All the best,
Chris

Thanks Chris

As always you guys rock!

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!"