I cannot display my database information on the page

Asked

Viewed 642 times

1

I created my database php, made the connection with the mysql, but does not show the data that exist in my table on Phpmyadmin, what appears is this:

" . resultado['nome'] ."
". resultado['email'] . "
". resultado['turno'] . "
" . resultado['uf'] . "
"; } ?>

... Follow my code below:

<?php

$host = "localhost";
$bd = "alunos";
$user = "root";
$senha = "";

$conexao = mysql_connect ($host, $user, $senha) or die (mysq_error());
mysql_select_db($bd, $conexao);

$tabela = msql_query("SELECT * FROM informacoes") ;
    while($resultado = mysql_fetch_array($tabela)){
       echo "informacoes:". $resultado['idaluno'] . "<br/>" . resultado['nome'] ."<br/>". resultado['email'] . "<br/>". resultado['turno'] . "<br/>" . resultado['uf'] . "<br/>";      
    }

?>
  • 2

    Function name is wrong, is mysql_query and not msql_query

2 answers

1

Variables are accessed with $ before the name: $result and no result

  • It looks like this: ". $result['name'] ." ". $result['email'] . " ". $result['turn'] . " . $result['Uf'] . " "; } ?>

1


Two problems with the vehicle:

  1. Absence of $.
  2. If it is displaying the source code then it is not running, check if it is accessing using localhost (right) or file:\\\ (wrong).
  • I put $, and it looked like this: ". $result['name'] ." ". $result['email'] . " ". $result['turn'] . " " . $result['Uf'] . " "; } ?>

  • @Ruanrodrigues and the second problem, verified?

  • I did. Is there anything that might disturb the database connection? Firewall type, antivirus, etc...

  • look firewall never blocked my connection, and as ta the url is the right way or wrong?

  • file://C:/wamp/www/database%20de%20dados/html.html

  • Change the extension to . php, access from localhost

  • Thank you very much, helped a lot, there asks to use the mysqli... More my problem for now has been solved. I thank you.

  • I don’t have enough reputation to upvote yet.

Show 3 more comments

Browser other questions tagged

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