This is my Connection class in the database
class Conection {
private $_host = 'ALISON\MSSQLSERVER2';
private $_user = 'banco';
private $_pass = '123456';
private $_database = 'aulateste';
private $_con;
function __construct(){
$this->conecta();
}
public function conecta() {
$_coninfo = array("Database" =>$this->_database, "UID" =>$this->_user, "PWD" =>$this->_pass);
$_con = sqlsrv_connect($this->_host, $_coninfo);
if($_con) {
echo "Conexão estabelecida";
}else{
echo "Conexão não estabelecida";
die( print_r( sqlsrv_errors(), true));
echo "<br>";
}
}
}
This is my insert method:
public function cadastrar_autor($Id_autor,$Nome_autor, $Sobrenome_autor){
$sql = "INSERT INTO tbl_autor VALUES($this->Id_autor,$this->Nome_autor,$this->Sobrenome_autor)";
$sql_inserir = sqlsrv_query($sql,$this->conect);
if($sql_inserir > 0){
echo"Cadastrou";
}else{
die( print_r( sqlsrv_errors(), true));
}
}
Error
An invalid parameter was passed to sqlsrv_query