While with Href - PHP [closed]

0

Expensive;

I have this code:

<?php

    $sql = "select * from tabela where codsegur = '7562315'";

    $stm = $conexao->prepare($sql);
    $stm->execute();
    $count = $stm->rowCount();

    if ($count > 0) {
       while($row = $stm->fetch())  {
           echo "<a href=caminho/".$row['caminho']."></a>";
       }
    }
?>

The variable $row gets the SQL return above, and the array path would be the path where the file would be. In this case, I wanted to concatenate href along with the path and generate the file link on my page for download. In short, when you access the page and enter the code (7562315) in the form, present the file in question, whose file is with its path set to array (path). To not need the whole form, I set the direct code in SQL to give the feedback I need.

When I do this process, nothing happens, and does not generate errors. When I give echo to $row['caminho'] , the path that is set in the database appears.

Can anyone help me with what / where I'm going wrong?

Note: The connection to the database is Ok.

Thank you.

    
asked by anonymous 26.04.2018 / 19:01

1 answer

2

Your error is in the absence of quotation marks for the href parameter. The correct would be:

echo "<a href='caminho/".$row['caminho']."'></a>";

By leaving the contents within the href parameter in single quotation marks.

    
26.04.2018 / 19:05