How to change Mysql to Mysqli [duplicate]

0

Well, Half of my project is using mysql plus I added a new function that uses mysqli which is generating some conflicts in the database. Or it saves what is in mysql or what is in mysqli. I tried to switch to mysqli but could not make it work.

When I use this mysql script mysqli does not work

<?php

error_reporting(0);
ini_set(“display_errors”, 0 );

$conectar = mysql_connect("localhost","root","") or die ("Erro na conexão");
mysql_select_db("tcc")or die ("Base não encontrada");
?>

This only works mysqli and not mysql

<?php
	$servidor = "localhost";
	$usuario = "root";
	$senha = "";
	$dbname = "usuarios";
	
	//Criar a conexao
	$conn = mysqli_connect($servidor, $usuario, $senha, $dbname);
?>

I would like to know how I change mysqli pro mysql I have already tried removing the i from mysqli more than right.

I changed my connection to mysqli_ and I can not login with user possibly because it is not connecting to the database because the codes are in mysql _

The login code

<?php
session_start();
$usuariot = $_POST['usuario'];
$senhat = $_POST['senha'];
include_once("conexao.php");

$result = mysql_query("SELECT * FROM usuarios WHERE login='$usuariot' AND senha='$senhat' LIMIT 1");
$resultado = mysql_fetch_assoc($result);
//echo "Usuario: ".$resultado['nome'];
if(empty($resultado)){
	//Mensagem de Erro
	$_SESSION['loginErro'] = "Usuário ou senha Inválido";
	
	//Manda o usuario para a tela de login
	header("Location: index.php");
}else{
	//Define os valores atribuidos na sessao do usuario
	$_SESSION['usuarioId'] 			= $resultado['id'];
	$_SESSION['usuarioNome'] 		= $resultado['nome'];
	$_SESSION['usuarioNivelAcesso'] = $resultado['nivel_acesso_id'];
	$_SESSION['usuarioLogin'] 		= $resultado['login'];
	$_SESSION['usuarioSenha'] 		= $resultado['senha'];
	
	if($_SESSION['usuarioNivelAcesso'] == 1){
		header("Location: administrativo.php");
	}else{
		header("Location: usuario.php");
	}
}
?>

I tried changing mysql_query and mysql_fetch_assoc by adding i but not enough I can not log in

    
asked by anonymous 03.11.2017 / 11:51

0 answers