My code:
<?php
include("funcoes.php");
?>
<HTML>
<HEAD>
<META charset = "UTF-8">
<TITLE>Menu</TITLE>
</HEAD>
<BODY>
<center>
<form method="POST" >
Marca: <input type="text" name="marca"></a><BR>
Preço: <input type="number" name="preco"></a><BR>
Polegadas: <input type="number" name="tamanho"></a><BR>
Tipo de Tela: <select name="tipoTela">
<option value="1"> LED</option>
<option value="2"> LCD</option>
<option value="3"> Plasma</option>
<option value="4"> CRT</option>
<option value="5"> DLP</option>
</select> <BR><BR>
Formato: <select name="formato">
<option value="1"> Convencional</option>
<option value="2"> Widescreen(HD)</option>
</select> <BR><BR>
Fabricante: <select name="fornecedor">
<? $fornecedores = buscarFornecedores();
foreach ($fornecedores as $fornecedores) { ?>
<option value="<? echo $fornecedores; ?>">
<?php echo $fornecedores; ?> //linha 34
</option>
<? } ?>
</select>
</form>
<center>
</BODY>
</HTML>
The function:
function buscarFornecedores (){
echo "oi1";
$qry = "SELECT * FROM public.fornecedor";
$result = pg_query($qry) or die("Cannot execute query: $qry
");
while($row = pg_fetch_object($result)){
$fornecedores[] = $row;
}
return $fornecedores;
}
The error is this:
Undefined variable: fornecedores in /var/www/cadastro.php on line 34
The problem is that in a computer of a friend, the same code works normally, with the same stuffs.