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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:25:19+00:00 2026-06-06T02:25:19+00:00

I’m sure there is an easy answer to this question, but for the life

  • 0

I’m sure there is an easy answer to this question, but for the life of me, I can’t find it. I’m using PHP5 and I’m trying to change the value of a class variable, but it doesn’t appear to change. For example, I have something like this:

<?php

include_once "../includes/global.php";

loadDAOs('yweightGroups','yweightCourses','yweightUsers','user','yweightData');



class yweight {

private $header_includes;
private $user;
private $yweightUser;

//Description:
//  Constructor.
//Parameters:
//  -none-
//Returns:
//  -nothing-
function __construct() {
    global $r_action;
    global $r_page;

    $this->user = login_required(); 

    if(!$this->user || empty($this->user)){
        die();
        goHome();   
    }

    $this->header_includes = "";

    if(isset($r_action)) {
        $this->$r_action(); 
    }
    else if (isset($r_page)) {
        $this->$r_page();   
    }
    else {
        $this->draw();  
    }       
}

//Description:
//  Draws the YWeight page
//Parameters:
//  -none-
//Returns:
//  -nothing-
function draw() {
    global $r_page;     
    global $colorDAO;
    global $yweightUsersDAO;

    ob_start();
    ?>
    <script type='text/javascript' src="./yweight.js"></script>
    <link rel="stylesheet" type="text/css" href="yweight.css" />
    <?php

    $this->header_includes .= ob_get_clean();

    $col = $colorDAO->read(17);
    print_top("",$this->header_includes,"resources","",$col->value,$col->fontcolor);

    $users = $yweightUsersDAO->GetByUserID($this->user->id);

    if(!$users){
        echo "<div class='msg_failed'>You are not authorized to view this page.</div>";
        die();
    }

    $this->yweightUser = $users;
    echo serialize($this->yweightUser[0]);
    ?>
    <div id="yweight_area"></div>
    <script type='text/javascript'>
        <?php
        if($users[0]->yweightUsers_intern == 0)
            echo "drawPage('main_participant');";
        else
            echo "drawPage('main_intern');";
        ?>
    </script>
    <?php   
    print_bottom();
    echo ob_get_clean();

}           


//Description:
//  Draws the main intern page.
//Parameters:
//  -none-
//Returns:
//  -nothing-
function main_intern() {
    ob_start();
    echo "hello intern";
    echo ob_get_clean();
}

//Description:
//  Draws the main participant page.
//Parameters:
//  -none-
//Returns:
//  -nothing-
function main_participant() {
    global $yweightDataDAO;
    ob_start();
    $this->yweightUser = $this->yweightUser[0];
    echo serialize($this->yweightUser);
    ?>
    <div id="banner_div">
        <img class="banner" width="927" src="images/ParticipantsMain.jpg" />
        <img id="tracker_btn" class="std_btn" src="images/trackerButton.png" />
        <img id="summary_btn" class="std_btn" src="images/summaryButton.png" />
        <img id="requirements_btn" class="std_btn" src="images/reqButton.png" />
    </div>
    <div id="discussion_board_input_div">
        <textarea id="discussion_board_input" />
        <?php
        echo build_btn("green",100,25,"Submit","","","","",
            'submit_post()',"margin-top:5px; margin-bottom:5px; float:right;");
        ?>
    <div class="clear_floats" />
    </div>
    <div id="discussion_board_div">

    </div>
    <?php
    echo ob_get_clean();
}

function submit_post(){
    global $yweightDataDAO;
    global $userDAO;
    global $r_post;
    echo serialize($this->yweightUser);
    $userDataID = $yweightDataDAO->GetByUserID($this->yweightUser->user_id);

    if($userDataID){
        $userData = $yweightDataDAO->read($userDataID);
        $userDiscussion = unserialize($userData->yweightData_discussionBoard);
    }

    $userDiscussion[$this->user->firstName .  time()] = $r_post;

    $userData->yweightData_discussionBoard = serialize($userDiscussion);

    $yweightDataDAO->save($userData);
}

}


$recs = new yweight();

?>

submit_post() is an ajax called function. The error I’m getting is that it says $this->yweightUser is undefined. I didn’t orignally include all of the code because I thought that I was just misunderstanding how class variables are declared.

  • 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-06T02:25:23+00:00Added an answer on June 6, 2026 at 2:25 am

    You have a typo. Use __construct. Two (_ _) underscores. Your fooVariable is never getting set. After it gets set it works fine.

    Update: You only set $this->yweightUser in your function draw() method. If you don’t call draw() before ajax_post() or w/e, it will not be defined.

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

Sidebar

Related Questions

This could be a duplicate question, but I have no idea what search terms
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

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.