0
I’m new with the development in php and was seeing some examples of select in a table in mysql on the net, but no successful execution.
The code is as follows::
$conexao = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die (mysql_error());
mysql_select_db(DB_NAME, $conexao) or die (mysql_error());
// CONNECTION ------------------------------------------------------------------
$query = "SELECT * FROM formcontato";
$result = mysql_query($query);
while($fetch = mysql_fetch_row($result)){
echo $fetch[0];
}
When the code is executed, it returns the error:
Warning: mysql_fetch_row() expects Parameter 1 to be Resource, Boolean Given in select.php on line 13
What’s wrong with the code above?
mysql_connect
was considered discontinued, useMySQLi
orPDO
to connect to the bank. link with further reading on these extensions ofphp
that manage connections to a database.– MarceloBoni
So Marcelo, obg for the feedback. About Mysqli here gave an error that was related to its activation, as if it had not enabled, but thank you I will read about these 2 forms of connections.
– Junior
Means your query has failed ...
– rray
on your server go to/phpinfo.php and look for
mysqli
orpdo
they inform you if the extensions are installed on your server, if they are not just installing– MarceloBoni