Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I don't know why I am having this error. I'm using WampServer. I am trying to configure my database thru OOP and I came up with this error.

Parse error: syntax error, unexpected '?>', expecting function (T_FUNCTION)

 <?php
    Class Database{
        private $_host = null;
        private $_user = null;
        private $_pass = null;
        private $_db = null;
        var $con = false;

    public function connects($host, $user, $pass, $db){
        $this->_host = $host;
        $this->_user = $user;
        $this->_pass = $pass;
        $this->_db = $db;

        $this->con = mysql_connect($this->_host, $this->_user, $this->_pass);
        if(!$this->con){
            return false;
        }
        else{
            $sql = mysql_select_db($this->_db);
            if(!$sql){
                return false;
            }
            else{
                return true;
            }
        }
    } 
?>
share|improve this question
6  
This question appears to be off-topic because it is about playing "spot the missing bracket" game. –  Juhana Aug 8 at 8:48
 
Dont'use mysql.it was deprecated.use PDO or mysqli –  samitha Aug 8 at 8:48
 
Close a bracket before ?> –  Mircea Soaica Aug 8 at 8:48
 
oh shit! sorry for the lame question.. was very nice of you for noticing it. –  Edgar Aug 8 at 9:21
add comment

closed as off-topic by Juhana, Akam, HAL9000, fancyPants, Dave Aug 8 at 10:49

  • This question does not appear to be about programming within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

up vote 1 down vote accepted

You are missing

}

to finalize the class Database {

To avoid this, use proper line indention and follow the Zend Coding Style Guide

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.