what is the error of this php code? [closed]

-3
<?php

//paso 1 es conectarnos con el servidor //esta manera ya esta obsoleta!!
    $link = mysql_connect('localhost', 'root', '');
    if(!$link){
        echo'No Se Pudo Establecer Conexion Con El Servidor: '. mysql_error();
    }else{
    //Paso 2 es seleccionar la base de datos
        $base = mysql_select_db('full',$link);
        if(!$base){
            echo'No se encontro la base de datos: '.mysql_error();
        }else{
    //Paso 3 es hacer la sentencia sql y ejecutarla
            $sql = "SELECT * FROM full";
            $ejecuta_sentencia = mysql_query($sql);
            if(!$ejecuta_sentencia){
                echo'hay un error en la sentencia de sql: '.$sql;
            }else{
    //Paso 4 es traer los resultados como un array para imprirlos en pantalla
                $full = mysql_fetch_array($ejecuta_sentencia);}



        }
    }

function portada($full){

 $salida = $salida . '<div class="col-md-4">';
 $salida = $salida . '<h2>' . $full["nombre"] . '</h2>';
 $salida = $salida . '<img src="data:image/jpg;base64,'. base64_encode($full['imagen']) .'" alt="'. $full['nombre'] . '" class="">';
 $salida = $salida . '<p>' . $full['descripcion'] . '</p>';
 $salida = $salida . '<p><a class="btn btn-danger" href="#"> Antes ' . $full['precio'] . '<strong> Ahora ' . $full['precio']. '</strong></a></p> </div>';        




return $salida;
}




?>
    
asked by Isaac 17.06.2018 в 19:03
source

2 answers

1

You are using the mysql_* , which at the time of programming in php are not safe. You should use mysqli_* .

And the second, as Mario says, your $sql sentence also requires $link to execute. Without it, it produces an error.

Even so it would be convenient that you give us more details about your error in particular.

    
answered by 17.06.2018 в 20:35
0

In addition to the answers that have been written to you, I should ask: Is the database and table named equal: "full"?

You are selecting the "full" database using:

mysql_select_db('full',$link);

And doing a query on a table called "full":

$sql = "SELECT * FROM full";

Instead of using mysql_ * or mysqli_ * I think you should use PDO which currently has support and not mysql__ or mysqli __

    
answered by 17.06.2018 в 21:43