Problem with Echo php

Asked

Viewed 195 times

-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!"; }...?

  • 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!"; }..."

  • the source code is printed on the screen in place of the true result?

  • yes rray, but not the whole source code, just that excerpt that I quoted.

  • 1

    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.

  • See if any of these procedures resolve. How you are accessing your php in the browser address bar.

  • Fernando, the code entered in the question is all the code of the file? If not, have to post the full code?

  • 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.

  • <? does not work properly if the short_open_tag is not enabled, another cause of this is when you access the url as file:///algum_arquivo.php.

  • Fernando, change the <? for <?php as in the reply @rray quoted.

  • Okay, people really worked, thank you all very much. I can’t believe I’ve been fighting this mistake for four hours '-'.

  • Argh, got it. The browser played <? ... if ($count > as a great HTML tag, and what comes next, as content.

Show 7 more comments

1 answer

0

Browser other questions tagged

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