problems with signs of a mysql query with php

Asked

Viewed 28 times

0

 <div class="form-group">
        <label for="inputCNPJ">Atividade Primária</label>
        <br />
        <select name="id_cnae" class="browser-default custom-select">
                <option value=0>Atividade Primária</option>
                <?php                                
                        $sql = mysqli_query($conn, "SELECT id_cnae, descricao FROM CNAE") or die(mysqli_error($conn));
                        while($aux = mysqli_fetch_assoc($sql)) { 
                ?>
                <option value='<?php echo $aux["id_cnae"]?>'><?php echo $aux["descricao"] ?>
                </option>
                <?php
                        }
                ?>
        </select>
</div>

I’m having problems at the front, the result comes out with symbols instead of Ç and accentuation, my html already has UTF-8

  • Dear Jonas, you have to adjust the connection too, the structure of the bank (maybe it is already ok) and save your . php in UTF-8 without "B O M". It’s detailed in the question I wrote in your

1 answer

-2

Add <meta charset='utf-8'> at the header of your HTML file.

OR

Try to change your query for SELECT id_cnae, descricao FROM CNAE collate utf8_unicode_ci. But I suggest you change the collation (if that’s what you call it) of your tables on the bench.

Source: Another question from Sopt

  • I already added, but it didn’t work

Browser other questions tagged

You are not signed in. Login or sign up in order to post.