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

  • SEARCH
  • Home
  • 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 6891637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:26:06+00:00 2026-05-27T06:26:06+00:00

Finally, I’m getting into OOP and attempting to put together my first class. However,

  • 0

Finally, I’m getting into OOP and attempting to put together my first class. However, my IDE (NetBeans) throws up an error on the last function’s (sanitize()) closing parentheses. This doesn’t happen when all the class contents are extracted from the class.

Here’s my code:

class db_class {

    $error_log = false; 

    function connect($db_host, $db_user, $db_pass) {
        $connect = mysql_connect($db_host, $db_user, $db_pass);
        return $connect;
    }

    function select_db($db_database) {
        $select_db = mysql_select_db($db_database);
        return $select_db;
    }


    function array_prepare($data) {
        $size = sizeof($array);

        foreach($array as $k => $v) {
        $keys[] = $k;
        }

        $size_md = sizeof($array[$keys[0]]);
        for($i = 0; $i < $size_md; $i++) {
            $value .= '(';
            for($j = 0; $j < $size; $j++) {
                    $value .= "'".$array[$keys[$j]][$i]."',";
            }
            $value = rtrim($value, ',');
            $value .= '), ';
        }
        $value = rtrim($value, ',');

        return $value;
    }

    function sanitize($data) {
        if(is_array($data)) 
        foreach($data as $k => $v) 
            $data[$k] = sanitize($v); //recursive
        elseif(is_string($data))
            $data = mysql_real_escape_string($data);
        return $data;
    } // <- where the error is thrown up  

}

I really don’t see what I’ve done wrong, and the suggestions offered by NetBeans are many (it offers like 10 explanations for the syntax error). Can anyone pick up what could be causing this issue?

Any help would be greatly appreciated!

  • 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-27T06:26:07+00:00Added an answer on May 27, 2026 at 6:26 am

    You’re missing a visibility declaration on your property.

    In other answers they have you use var, however I would advise you to use PHP5 visibility declarations; public, protected or private. The visibility of the variable should be based on the need for that piece of data. As a general rule though, you should limit the amount of properties that are declared public. Ultimately, you have no control over the data that can be assigned to a public property.

    Furthermore, you should put a visibility declaration on your functions as well. Not having any visibility declaration will mark them as public, this is probably not what you’ll want for all functions in a class.

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

Sidebar

Related Questions

I finally let windows nag me into upgrading from IE6 to 8. Now in
I'm finally getting my team to embrace source code management now that we're working
I've finally completed a working version of my first ever CSS-supported site (thanks to
After finally getting down to upgrading to FF 3.5, I noticed that some of
Finally checked out L2E framework and ran into problems almost instantly. Yeah, i know...
Finally getting to do some Silverlight development and I came across MVVM. I am
Finally, thanks to most of you, I got my first app approved by Apple.
Finally, I find some article in http://code.google.com/intl/en/web/ajaxcrawling/docs/getting-started.html msnbc use this method. Thanks for all
Finally moved to Rails 3 for a new project and already running into a
I finally managed to trim my code and put all the TableViewController-Methods in a

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.