-1
I’m trying to search a system here of a college job, but when it displays the result appears:
0) { echo "$count resultados encontrados!"; } while ($dados = mysql_fetch_array($sql)) { echo "$dados[nome] $dados[email]"; } ?>
the code is like this:
include "config.php";
$busca = $_POST['busca'];
$sql = mysql_query("SELECT *
FROM funcionario
WHERE nome LIKE '%$busca%' OR email LIKE '%$busca%' ");
$count = mysql_num_rows($sql);
$noticia = mysql_fetch_assoc($sql);
if ($count == 0) {
echo "Nenhum resultado!";
}
if ($count > 0) {
echo "$count resultados encontrados!";
}
while ($dados = mysql_fetch_array($sql)) {
echo "$dados[nome] $dados[email]";
}
Could you help me find the mistake please?
Fernando, could explain better the error that appears, is appearing that php code
0) { echo "$count resultados encontrados!"; }...
?– KaduAmaral
type, on the page that would be displayed the result, instead of printing on the page that has some result, it appears written these commands 0) { echo "$Count found results!" ; }... Almost like this: echo "0) { echo "$Count results found!"; }..."
– Fernando
the source code is printed on the screen in place of the true result?
– rray
yes rray, but not the whole source code, just that excerpt that I quoted.
– Fernando
This is strange. If you printed all the code I would say that PHP is not being interpreted (by the lack of a
<?php
, perhaps), but the one of printing only a fragment... bizarre.– bfavaretto
See if any of these procedures resolve. How you are accessing your php in the browser address bar.
– rray
Fernando, the code entered in the question is all the code of the file? If not, have to post the full code?
– KaduAmaral
accessing as localhost/busca_func.php, I will check here rray. Kadu this is the whole search file. , I just didn’t put the <? > here in the stack.
– Fernando
<?
does not work properly if the short_open_tag is not enabled, another cause of this is when you access the url asfile:///algum_arquivo.php
.– rray
Fernando, change the
<?
for<?php
as in the reply @rray quoted.– KaduAmaral
Okay, people really worked, thank you all very much. I can’t believe I’ve been fighting this mistake for four hours '-'.
– Fernando
Argh, got it. The browser played
<? ... if ($count >
as a great HTML tag, and what comes next, as content.– bfavaretto