Substr () does not work

-2

I can not understand why the substr is not working. Here is the code:

<?php

    // conexão com bd

    $host = "localhost";
    $user = "root";
    $pass = "";
    $db = "loja";

    $conexao = mysqli_connect($host, $user, $pass, $db);

    $consulta = "Select concact(substr(nome,1,10),'...') as nome from produtos";
    $resultado = mysqli_query($conexao, $consulta);

    while($linha = mysqli_fetch_array($resultado)){

    ?>

    <p> <?php echo $linha['nome']; ?> </p>

    <?php


    }
?>
    
asked by anonymous 27.12.2018 / 13:59

2 answers

1

The error is in the "concact" command, where the correct one is "concat".

    
27.12.2018 / 14:03
1

The CONCAT function in your query is spelled wrong, change it will work:

 $consulta = "SELECT CONCAT(SUBSTR(nome,1,10),'...') AS nome FROM produtos";
    
27.12.2018 / 14:11