-2
I cannot understand why the substr is not working. Follow 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
}
?>
Which is the expected output and which was the obtained output? What are the records present in the database?
– Woss
I expected to leave, for example, the name of the product followed by ellipsis after the tenth character (ex: Phi LCD TV...) but points out the following error: Warning: mysqli_fetch_array() expects Parameter 1 to be mysqli_result, Boolean Given in C: xampp htdocs December test.php on line 15
– Leonardo Henrique
Your select is wrong. Try running it straight in mysql to see the full message, but probably concact should be Concat
– Rafael Mena Barreto
Please do not omit information the next time you ask. If you have made a mistake, put at all times the error message.
– Woss
Gee, I didn’t even notice the mistake. Thank you very much!
– Leonardo Henrique