Boa noite pessoal, estou aqui com um problema. Com as atualizações das versões do php as conexões com o banco de dados ficaram obsoletas no mysql. e fica indicando que o sistema está depreciado.
Teria de mudar para a conexão via PDO ou Mysqli, mas pelo que vi, a mudança para PDO é muito complexa, já a do Mysqli é um pouco mais tranquila, porém mesmo no Mysqli não consigo fazer.
Então, aqui a baixo mostro minha conexão atua ao banco de dados, feita mysql_pconnect
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_sistemas = "localhost";
$database_sistemas = "banco";
$username_sistemas = "usuario";
$password_sistemas = "senha";
$sistemas = @mysql_pconnect($hostname_sistemas, $username_sistemas, $password_sistemas) or trigger_error(mysql_error(),E_USER_ERROR);
?>
Então, alterar aí para o Mysqli até li algumas coisas, o porblema é que o sistema tem pra mais de 50 arquivos, aí eu teria de trocar não sei quantas coisas em cada arquivo um por um.
Abaixo aqui, um arquivo de cadastro do sistema. Se eu ver o que tem de ser alterado neste arquivo e o arquivo de conexão acima mostrado anteriormente, aí posso ir tentando fazer no restante.
<?php require_once('../Connections/sistemas.php'); ?>
<?php require_once('../Connections/sistemas.php'); ?><?php require_once('../Connections/sistemas.php');
require_once('../include.php');
?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "admin1";
$MM_donotCheckaccess = "false";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && false) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "index.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO clientes (Id, usuario, senha, nivel_acesso, nome, cpf, ---o, data_nascimento, cidade, uf, endereco, complemento, bairro, cep, telefone, celular, email, obs, limite, supervisor, ip, servico) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['Id'], "int"),
GetSQLValueString($_POST['usuario'], "text"),
GetSQLValueString($_POST['senha'], "text"),
GetSQLValueString($_POST['nivel_acesso'], "text"),
GetSQLValueString($_POST['nome'], "text"),
GetSQLValueString($_POST['cpf'], "text"),
GetSQLValueString($_POST['---o'], "text"),
GetSQLValueString($_POST['data_nascimento'], "text"),
GetSQLValueString($_POST['cidade'], "text"),
GetSQLValueString($_POST['uf'], "text"),
GetSQLValueString($_POST['endereco'], "text"),
GetSQLValueString($_POST['complemento'], "text"),
GetSQLValueString($_POST['bairro'], "text"),
GetSQLValueString($_POST['cep'], "text"),
GetSQLValueString($_POST['telefone'], "text"),
GetSQLValueString($_POST['celular'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['obs'], "text"),
GetSQLValueString($_POST['limite'], "text"),
GetSQLValueString($_POST['supervisor'], "text"),
GetSQLValueString($_POST['ip'], "text"),
GetSQLValueString($_POST['servico'], "text"));
mysql_select_db($database_sistemas, $sistemas);
$Result1 = mysql_query($insertSQL, $sistemas) or die(mysql_error());
$insertGoTo = "confirme.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
$colname_dados = "-1";
if (isset($_SESSION['MM_Username'])) {
$colname_dados = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
}
mysql_select_db($database_sistemas, $sistemas);
$query_dados = sprintf("SELECT * FROM usuarios WHERE usuario = '%s'", $colname_dados);
$dados = mysql_query($query_dados, $sistemas) or die(mysql_error());
$row_dados = mysql_fetch_assoc($dados);
$totalRows_dados = mysql_num_rows($dados);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
Quem puder me ajudar aí, pois depois vou ter um imenso trabaçho de rever um a um arquivo para consertar.
Obrigada a todos.