Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8124819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:35:30+00:00 2026-06-06T06:35:30+00:00

Im having problems with a method in a class file: public static function getPageLeft($pid)

  • 0

Im having problems with a method in a class file:

    public static function getPageLeft($pid)
{
    self::_dbConnect();
    echo "now " .$pid;
    $pid--;
    echo " after ". $pid;
    $data = mysql_query("SELECT id FROM evening_pages WHERE id='".$pid."'") or die(mysql_error());
    $rows = mysql_num_rows($data);
    if($rows == 1){
        echo "  in  ";
        return $data;

    }elseif($pid != self::getMinPage()){
        self::getPageLeft($pid);
        echo " Current: " . $pid . " min: " .self::getMinPage();
    }
}

I have the echos in there for debug only, and im getting:

now 22 after 21now 21 after 20 Current: 21 min: 1

This code is to find the next page left in a database driven CMS in case the client deletes a row from the database, it finds the next lower value.

So page id is 22 that your on, looks for id 21 in database, if its not there it should return 0 for the rows and move on and try again but on id 20, but there IS an entry for id = 20.

Anyone spot any issues with the code?

Also getting this error when it tries to find a page which doesnt exist before the current page, eg on page 22 but there is no ID for 21:

Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in /home/prelas/public_html/index.php on line 37

the code there is (line 37 is while):

    $getPageLeft = sql::getPageLeft($pid);
while($row = mysql_fetch_array($getPageLeft)){
        $pageleft = $row['id'];
    }

Many thanks.

Just a quick edit: ” in ” never gets echoed, but yet when there is no deleted pages the navigation works fine.

Further edit: The code which makes use of the code (by like 37):

    $navigation = '<div id="direction">
      <span class="inNav"> <a href="index.php?pid='. $min .'">&lt;&lt;</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="index.php?pid='. $pageleft .'">&lt;</a>&nbsp;&nbsp; </span><span class="black">&bull;</span><span class="inNav">&nbsp;&nbsp;&nbsp;<a href="index.php?pid='. $pageright .'">&gt;</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="index.php">&gt;&gt;</a></span>
  </div>'

So you can see it uses $pageleft in there however when its dealing with blank pages the value is nothing (empty).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T06:35:32+00:00Added an answer on June 6, 2026 at 6:35 am

    why don’t you write the SQL statement to get the next lower ID? For example:

     SELECT `id`
       FROM `evening_pages`
       WHERE `id` < ?
       ORDER BY `id` DESC
       LIMIT 1
    

    Or:

     SELECT MAX(`id`)
       FROM `evening_pages`
       WHERE `id` < ?
    

    That way, you only have to check if something has been returned by the query. Less code, less overhead for database requests.

    The mysql extension is being phased out. Learn about using mysqli or PDO, and read up on the dangers of SQL injection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having problems using the update method of scala.collection.immutable.HashMap.I don't see the reason
Good morning all, I'm having a few problems with a method in my C#
I'm having a problem de-compressing a ZIP file using Java. The method is below.
I'm having problems getting an uploaded file (HTTPPostedFile) and an object posted to an
I'm having problems in implementing a class in a DLL in the same way
I'm having the following method in an applet which is called via JavaScript public
i having a problem with a global method called returnDayNumber. If i call the
I am having a problem with the Document.SaveAs method in Word VBA with large
I'm having a problem with Python's subprocess.Popen method. Here's a test script which demonstrates
I am having a strange problem: In -(void)viewWillAppear:(BOOL)animated method I use: [[UIApplication sharedApplication] setStatusBarHidden:YES

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.