Jump to content

Having problems with my first class


Spring

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.