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 979221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:11:07+00:00 2026-05-16T04:11:07+00:00

I was turned on to nstrees from another question, and have been working through

  • 0

I was turned on to nstrees from another question, and have been working through the script. It was last updated in 2005 and relied on some stuff that has since apparently been deprecated like HTTP_POST_VARS which I wasn’t immediately familiar with since I’ve been doing PHP for only a little less than a year.

Anyways, the coding style seems weird to my rookie eyes, and I’d like a second opinion on what part of this function does:

// returns the first node that matches the '$whereclause'.
// The WHERE clause can optionally contain ORDER BY or LIMIT clauses too.
function nstGetNodeWhere ($thandle, $whereclause) {
    $noderes['l'] = 0;
    $noderes['r'] = 0;
    $res = mysql_query("SELECT * FROM ".$thandle['table']." WHERE ".$whereclause);
    if (!$res) { // problem area 1
        _prtError();
    } else {
        if ($row = mysql_fetch_array($res)) { // problem area 2
            $noderes['l'] = $row[$thandle['lvalname']];
            $noderes['r'] = $row[$thandle['rvalname']];
        }
    }
    return $noderes;
}

In the above code I marked the spots I’m not quite sure about as // problem area x, everything else is the original script.

Regarding PA1, is that just a check on whether the query was successfully run?

And PA2, NetBeans gives me a warning “Possible accidental assignment, assignments in conditions should be avoided.” … so I promptly changed that from = to == and of course broke the script, heh.

Thinking about it, I guess it’s just another error check on $res, this time to make sure that some data was actually returned?

Lastly, is this bizarre PHP or am I just too green to grok it?

Thanks dude(tte)s!

  • 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-05-16T04:11:08+00:00Added an answer on May 16, 2026 at 4:11 am

    Problem Area 1 is exactly what you think it is. It checks if the query ran successfully. Look at the documentation for mysql_query (since you use Netbeans you can also highlight the function name in the editor and hit F2 to get an inline popup). You’re looking for the “Return Values” section. Over there it says it will return FALSE (the boolean FALSE) on any errors.

    Checking

    if (!$res)
    

    is the same as checking for

    if ($res == false)
    

    Ideally you should be checking for

    if ($res === false)
    

    because it’s safer since PHP is very relaxed about variables == false, but I’d rather not confuse you with that right now. If you’d like you can start by reading about strong typing.

    Problem Area 2 is pretty common but will show a warning in Netbeans, yes. What it’s doing is assigning a value from mysql_fetch_array() into $row, and checking if that is now true or false, while also letting you use that same value now in $row in the following code block inside the if().

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

Sidebar

Related Questions

At some point in time I turned on a setting in Visual Studio 2005
Update: This turned into a blog post, with updated links and code, over at
CFMX 8 Enterprise I have turned on the Use J2EE session variables setting under
I have a treeview control in a Windows Forms project that has checkboxes turned
I have got the following problem since the server has safe mode turned on,
The idata I pulled from this URL needs to be turned into a sequence,
I don't want to deal with users who have javascript turned off, so I
I've turned on USB debugging. I have the latest HTC Sync and android SDK
I just turned on notices because it has some important information I need with
In a string grid I turned on goEditing so that the user doesn't have

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.