Não consigo acessar o banco de dados


#1
<?php $servidor = "mysqlXX.000webhost.com"; $usuario = "id209355_elias"; $senha = "0307liao"; $banco = "id209355_emprestimo"; @$conexao = mysql_connect($servidor, $usuario, $senha) or die (mysql_error()); $banco = mysql_select_db($banco, $conexao) or die (mysql_error()); ?>

Eu não sei o servidor correto, onde tem XX eu não sei qual é o número.


#2

localhost is your correct server


#3
<?php $servidor = "localhost"; $usuario = "id209355_elias"; $senha = "minha senha"; $banco = "id209355_emprestimo"; @$conexao = mysql_connect($servidor, $usuario, $senha) or die (mysql_error()); $banco = mysql_select_db($banco, $conexao) or die (mysql_error()); ?>

Não conectou. A página que possui o incude(‘conexao.php’); fica em branca!


#4

I take it you are using the new control panel?

If your are hit databases, then manage database does your database open in phpMyAdmin?

If it does then try your script again make sure you are using the correct password, hit change password and choose a new password carefully and copy/paste this into the script?


#6

Banco de dados não se conecta, (l)

php pra se conectar ......................................................................................................................... <?php

$login = $_POST[‘login’];
$senha = MD5($_POST[‘senha’]);
$connect = mysql_connect(‘localhost’,‘Id2401380_weliton’,‘maruan’);
$db = mysql_select_db(‘id2401380_weliton’);
$query_select = “SELECT login FROM usuarios WHERE login = ‘$login’”;
$select = mysql_query($query_select,$connect);
$array = mysql_fetch_array($select);
$logarray = $array[‘login’];

if($login == “” || $login == null){
echo"";

}else{
  if($logarray == $login){

    echo"<script language='javascript' type='text/javascript'>alert('Esse login já existe');window.location.href='cadastro.html';</script>";
    die();

  }else{
    $query = "INSERT INTO usuarios (login,senha) VALUES ('$login','$senha')";
    $insert = mysql_query($query,$connect);
    
    if($insert){
      echo"<script language='javascript' type='text/javascript'>alert('Usuário cadastrado com sucesso!');window.location.href='login.html'</script>";
    }else{
      echo"<script language='javascript' type='text/javascript'>alert('Não foi possível cadastrar esse usuário');window.location.href='cadastro.html'</script>";
    }
  }
}

?>
“um cadastro de usuario”

  • resposta do banco de dados

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /storage/ssd2/380/2401380/public_html/login.php:5 Stack trace: #0 {main} thrown in /storage/ssd2/380/2401380/public_html/login.php on line 5


#7

Hi @weliton!

Please lower your PHP version and try again: 000webhost cPanel > Settings > General > Change PHP version > 5.6


Also, for future I suggest you to migrate your code to mysqli_* functions set, as the mysql_* one is deprecated and removed as of PHP 7.0


#8

000webhost cPanel> Configurações> Geral> Alterar a versão do PHP> 7.1


#9

Change it to 5.6   


#10

NGiNX

um momento baixar o php


#12

NGiNX
a versão foi auterad


#14

I am sorry, I did not understand that…


#15

banco de dados

salvei a nov versão do php (5.6) mais aparece a seguinte msg

Warning: mysql_connect(): ProxySQL Error: Access denied for user ‘Id2401380_weliton’@‘2a02:4780:bad:f00d::c’ (using password: YES) in /storage/ssd2/380/2401380/public_html/cadastro.php on line 5

Warning: mysql_select_db(): ProxySQL Error: Access denied for user ‘’@‘2a02:4780:bad:f00d::c’ (using password: NO) in /storage/ssd2/380/2401380/public_html/cadastro.php on line 6

Warning: mysql_select_db(): A link to the server could not be established in /storage/ssd2/380/2401380/public_html/cadastro.php on line 6

Warning: mysql_query() expects parameter 2 to be resource, boolean given in /storage/ssd2/380/2401380/public_html/cadastro.php on line 8

Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in /storage/ssd2/380/2401380/public_html/cadastro.php on line 9


#17

Warning: mysql_connect(): ProxySQL Error: Access denied for user ‘Id2401380_weliton’@‘2a02:4780:bad:f00d::c’ (using password: YES) in /storage/ssd2/380/2401380/public_html/cadastro.php on line 5

This means your database credentials are incorrect.

Please make sure they are the same as the ones from 000webhost cPanel > Manage databases

If you have forgotten your DB password, please go to 000webhost cPanel > Manage databases > Locate DB > Manage > Change password


#18

nginx
host "localhost"
usuario BD "id2401380_weliton"
nome do banco de dados "id2401380_weliton"
senha “weliton”


#20

What is the website in question?


You have only two databases: id209355_machado and id209355_emprestimo.

Please use the correct credentials.