Error while trying to show mysql data in html

Asked

Viewed 73 times

-1

I am wanting to pull some things that is in a table in the database, only that error is appearing in the connection line of the database.

bd: Projects

table: projects

ERROR: Fatal error: Uncaught Error: Call to Undefined Function mysql_pconnect() in C: wamp64 www admin index.php on line 8 Error: Call to Undefined Function mysql_pconnect() in C: wamp64 www admin index.php on line 8

Code

<?php
// definições de host, database, usuário e senha
$host = "localhost";
$db   = "projetos";
$user = "root";
$pass = "";
// conecta ao banco de dados
$con = mysql_pconnect($host, $user, $pass) or trigger_error(mysql_error(),E_USER_ERROR);
// seleciona a base de dados em que vamos trabalhar
mysql_select_db($db, $con);
// cria a instrução SQL que vai selecionar os dados
$query = sprintf("SELECT nome, descricao, download FROM projetos");
// executa a query
$dados = mysql_query($query, $con) or die(mysql_error());
// transforma os dados em um array
$linha = mysql_fetch_assoc($dados);
// calcula quantos dados retornaram
$total = mysql_num_rows($dados);
?>
  • 1

    You spelled it wrong here: mysql_pconnect. There is no such function in the API. The right is mysql_connect. That’s all.

  • 1

    Consider using functions mysqli_* for the functions mysql_* depreciated form.

1 answer

1

Instead of using the method mysql_pconnect($host, $user, $pass) try to instantiate a mysql object, ie new mysql(localhost, root, senhadobanco, nomedobanco)

  • Now another error '-' ( ! ) Fatal error: Uncaught Error: Call to Undefined Function mysql_select_db() in C: wamp64 www admin index.php on line 6 ( ! ) Error: Call to Ufinended Function mysql_select_db() in C: wamp64 www admin index.php on line 6

Browser other questions tagged

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