I can not show an image with php

1

This is my code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>

<?php
    require("datos_conexion.php");
    $conexion=mysqli_connect($db_host,$db_usuario,$db_contra);
    if(!$conexion) {
        echo "Fallo al conectar con la BBDD";
        exit();
    }
    mysqli_select_db($conexion, $db_nombre) or die ("No se encuentra la base de datos");
    mysqli_set_charset($conexion, "utf8");
    $consulta="SELECT * FROM PRODUCTOS WHERE CÓDIGOARTÍCULO='AR01'";
    $resultado=mysqli_query($conexion, $consulta);
    while ($fila=mysqli_fetch_array($resultado)) {

        $ruta_img=$fila["FOTO"];
    }
?>  

<div>

    <img src="/pildoras/uploads/<?php echo $ruta_img;?>" alt="Imagen del primer artículo" width="25%">
</div>
</body>
</html>

I have the Github : link

I have the following line:

<img src="/pildoras/uploads/<?php echo $ruta_img;?>" alt="Imagen del primer artículo" width="25%">

For some reason the browser does not read the php part and then the path of the image remains as <img src="/pildoras/uploads/"

It must be a super silly syntax error, how do I fix it?

    
asked by Felipe Pino 22.09.2016 в 03:54
source

2 answers

1

First check that what you have in $fila["FOTO"] is the correct name, ie print it on the screen or make a var_dump .

Then check that the route is correct and remove the first bar on the route.

    
answered by 22.09.2016 в 04:03
0

I solved it, now it works. This is the code:

link

    
answered by 22.09.2016 в 18:33