Php does not show the contents of the mysql tab

0

I have a remote server with mysql. Create a database with a single table (all very simple, to see how it works). I write my php code to be able to access my database (with the authentication data well placed) but still does not show anything. Even doing echo at the beginning of everything. Here I leave the code

<?php
echo hola;
$HostName = "localhost";
$HostUser= "tt";
$HostPass= "enrique22";
$DatabaseName= "ejemplo";


echo "se cargo el archivo de configuracion"

if (!($iden = mysql_connect($HostName,$HostUser,$HostPass)))
        die("Error: No se pudo conectar con la BBDD");
if(!mysql_select_db($DatabaseName,$iden))
        die("Error: No existe la base de datos";

echo "estamos dentro de la base de datos";

$sentencia =  "SELECT * FROM employees";

$resultado = mysql_query($sentencia,$iden);
if(!$resultado)
        die(" Error: no se pudo realizar la consulta");

mysql_close($iden);


?>
    
asked by k1k4ss0 04.04.2018 в 12:54
source

1 answer

0

Well I think you should start by using the mysqli API ... for example:

<?php
   $link = mysqli_connect("127.0.0.1", "my_user", "my_password", "my_db");

   if (!$link) {
       echo "Error: Unable to connect to MySQL." . PHP_EOL;
       echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
       echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
       exit;
    }

   echo "Success: A proper connection to MySQL was made! The my_db database   is great." . PHP_EOL;
   echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;

    mysqli_close($link);
   ?>
    
answered by 04.04.2018 в 12:59