Jump to content

Having problems with my first class


Guest

Recommended Posts

This is my first class, go easy on me.

 

<?php
session_start();

class Train
{
    private $_clicked;
    private $_name;
    
    
    function __construct()
    {
      $this->_name = $_SESSION['name'];
      $this->_clicked = $_SESSION['clicked'];     
    }
    
    public function CheckLogged()
    {
        $this->_name == true ? "" : die("You must be logged in!)";
        
    }
    
    public function CheckClicked()
    {
        if(isset($_POST['go']))
        {
            $this->MysqlUpdate();
            $this->_clicked = 1;
        }
       
        
    }
    
    public function Clicked()
    {
       
       if(isset($this->_clicked))
       {   echo'
            <div id="train"><img src="images/train.jpg" alt="train image"/></div> 
             <div id="text">
              <span id="click">' . ucfirst($this->name). ' has gained 7 experience,<br /> and cannot train anymore today.         </span><form method ="post" name="train" action=""> </div>'; 

       }
       
       else
        {
          echo'
           <div id="train"><img src="images/train.jpg" alt="train image"/></div> 
            <div id="text"><span id="click">Click here to train your shinobi!</span>
             <form method ="post" name="train" action=""><input type="submit" name="go" value="train"  /></div>';}

        }

    
    private function MysqlUpdate()
    {
      $query = "UPDATE account_info SET experience = experience + 7 WHERE username = '$this->name'"; 
      $result = mysql_query($query) or die(mysql_error());
    }


}


?>

 

getting this error

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home2/producy2/public_html/arzania/train.class.php on line 6

Link to comment
https://forums.phpfreaks.com/topic/221580-having-problems-with-my-first-class/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.