0
I have an HTML/PHP code where there is a list field that I would like to return the database records. However, the field or variable appears in the list display instead of the BD values.
I can’t figure out the cause of the problem.
In the image below notice that a snippet of the code appears in the list of states " . $line['state_name']."
Below follows the code excerpt:
<td class="Label">Estado: </td> <!-- Aqui é uma FK -->
<td class="Field"><select id="slct1" name="estado">
<?php
include "connector.php";
$sql = "SELECT sigla_estado, nome_estado FROM estado;";
$resultado = mysql_query($sql) or die (mysql_error());
echo "<option value=''>Selecione</option>";
while ($linha = mysql_fetch_array($resultado)){
echo "<option value='".$linha['sigla_estado']."'>".$linha['nome_estado']."</option>";
}
?>
</select>
</tr>
Below is my Nector:
<?php
$Servidor = '*********';
$usuario = '*********';
$senha = '********';
$banco = '************';
mysql_connect($Servidor,$usuario,$senha) or die (mysql_error()) ;
mysql_select_db($banco) or die (mysql_error());
?>
not that it is the cause of the problem, but the function
mysql_connect
should not be assigned to a variable to be passed as the second parameter in the functionmysql_query
by chance ? something else, after loading the page, look for the source code through the browser, as it is using a PHP function within an HTML element, sometimes the rest of the error code (Warning if there is) may be around anyway.– William Novak
I could not notice the error, but there is a small detail in your HTML where the last </tr> should be a </td>
– Allan Andrade