FRIENDS, I migrated from vps and after that I started to have problems with the connection of bd mysql
, I made some more adjustments now I can not find the error, could you help me please, I have a php file that connects to the bank and another one sending the info follows.
The error is:
Host information: Localhost via UNIX socket # Warning: mysqli_query () at least 2 parameters, 1 given in /home/factor/public_html/formula/app/model.php on line 120
Warning: mysqli_query () expects at least 2 parameters, 1 given in /home/factor/public_html/formula/app/model.php on line 121
- php connects to bd -
<?php
$link = mysqli_connect("localhost", "xxxxx", "xxxxxx", "xxxxxx");
/* check connection */
if (!$link) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
printf("Host information: %s\n", mysqli_get_host_info($link));
/* close connection */
mysqli_close($link);
?>
--- php reading data ----
function select_empresa()
{
$sql = "SELECT e.id,e.nome_fantasia
FROM empresas e
LEFT JOIN empresas_acesso ea ON(ea.id_empresa = e.id)
WHERE ea.status = 1 AND DATE(now()) <= ea.data_expira ORDER BY nome_fantasia ASC";
if(self::myysqli($sql))
{
return $this->resultt(self::myysql($sql));
}
}
function check_acesso($empresa,$senha)
{
if($empresa)
{
$sql = "SELECT e.id
FROM empresas e
LEFT JOIN empresas_acesso ea ON(ea.id_empresa = e.id)
WHERE ea.status = 1
AND e.nome_fantasia = '{$empresa}'";
if(self::myysql($sql))
{
$data = $this->resultt(self::myysql($sql));
$id = $data[0]->id;
$senha = stripslashes(trim(str_replace(" ","",$senha)));
$sql = "SELECT e.nome_fantasia,ea.senha
FROM empresas_acesso ea
JOIN empresas e ON(e.id = {$id})
WHERE ea.id_empresa = {$id}";
if(self::myysql($sql))
{
$data = $this->resultt(self::myysql($sql));
if($data[0]->senha != $senha)
return 501;
else{
session_start();
session_destroy();
session_start();
$_SESSION['SS_empresa_id'] = $id;
$_SESSION['SS_empresa'] = $this->reg_caracter($data[0]->nome_fantasia);
$_SESSION['SS_start'] = strtotime('+7200 second'); // 2 horas expira sessao
header("Location:".SITE_URL."/formulario/entrada");
die();
}
}else
return 500; // empresa desabilitada no sistema
}
}
}
function get_dados_formulario()
{
if($_POST)
{
$set_values = $set_fields = $sep = null;
$set_v_descritores_chaves = $set_f_descritores_chaves = null;
$set_v_pares_adjetivos = $set_f_pares_adjetivos = null;
foreach($_POST['data'] AS $k=>$v)
{
if(!empty($v))
{
$pattern = '/^descritores_chaves/';
$pattern2 = '/^pares_adjetivos/';
$pattern_data = '/^data_nascimento/';
if(preg_match($pattern_data, $k, $matches, PREG_OFFSET_CAPTURE))
{
$v = $this->edit_datatime($v);
}
if(preg_match($pattern, $k, $matches, PREG_OFFSET_CAPTURE))
{
$set_v_descritores_chaves = ',"'. self::enter_eval($v) .'"';
$set_f_descritores_chaves = ',descritores_chaves';
}elseif(preg_match($pattern2, $k, $matches, PREG_OFFSET_CAPTURE)){
$set_v_pares_adjetivos = ',"'. self::enter_eval($v,1).'"';
$set_f_pares_adjetivos = ',pares_adjetivos';
}else{
$v = filter_var($v, FILTER_SANITIZE_STRING);
$set_fields .= $sep.$k;
$set_values .= $sep.'"'.$v.'"';
if(empty($sep)){$sep=',';}
}
}
}
$set_fields .= $set_f_descritores_chaves;
$set_values .= $set_v_descritores_chaves;
$set_fields .= $set_f_pares_adjetivos;
$set_values .= $set_v_pares_adjetivos;
$sql = "INSERT INTO cadastros ({$set_fields},data_entrada) VALUES({$set_values},now())";
//print_r($sql);
//exit;
if(self::myysql($sql))
{
die('cadastro realizado com sucesso');
}
}
}
private static function myysqli($sql)
{
if($sql)
{
mysqli_query("SET NAMES 'UTF8'");
return mysqli_query($sql);
}
}
private function resultt($sql)
{
if($sql)
{
while($row = mysql_fetch_object($sql))
{
$data[] = $row;
}
return $data;
}
}
private static function enter_eval($array,$fk)
{
$array_data = $sep = null;
if($array)
{
foreach($array AS $k=>$v)
{
if(!empty($fk))$v = (empty($v))?100:$v;
$v = filter_var($v, FILTER_SANITIZE_STRING);
$array_data .= $sep."'".($k)."'=>'".$v."'";
if(empty($sep)){$sep=',';}
}
return $array_data;
}
}
private function edit_datatime($value)
{
if($value)
{
$value = explode('/',$value);
$value = $value[2].'-'.$value[1].'-'.$value[0];
return $value;
}
}
private function reg_caracter($string){
$a = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ,./*';
$b = 'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr ';
$string = utf8_decode($string);
$string = strtr($string, utf8_decode($a), $b);
$string = strtolower($string);
return filter_var(stripslashes(trim(preg_replace('/\s+/','',strtolower($string)))),FILTER_SANITIZE_STRING);
}
}