I assume you want your functions to be defined within your MysqlClass
, but you're trying to define them outside. Naturally, PHP won't let you and gives you a unexpected T_PUBLIC
, because what does it even mean to define a function public in the global scope? Access modifiers only apply to class members.
Keeping your code properly indented is a good way to help you catch these kinds of errors, and also trying to read and understand the error. PHP tells you expect what the problem is.
class MysqlClass
{
private $nomehost = "localhost";
private $nomeuser = "root";
private $password = "xxxx";
private $nomedb = "intse";
private $attiva = false;
public function connetti()
{
if(!$this->attiva)
{
if($connessione = mysql_connect($this->nomehost,$this->nomeuser,$this->password) or die (mysql_error()))
{
$selezione = mysql_select_db($this->nomedb,$connessione) or die (mysql_error());
}
} else{
return true;
}
}
public function disconnetti()
{
if($this->attiva)
{
if(mysql_close())
{
$this->attiva = false;
return true;
} else {
return false;
}
}
}
}