mysql_query returning false

1

I'm trying to get information from my database plus it's not returning content, just a fake boolean:

require_once "config.php"; // database
$sql = mysql_query("SELECT * FROM home") or die("MySQL error:".mysql_error()); 
$result = mysql_fetch_array($sql);
var_dump($result);
//echo $result['conteudo'];
while($info = mysql_fetch_array( $sql )) {
  echo $info['conteudo'];
} 

A photo of the result: link
Any idea what might be happening?

    
asked by anonymous 04.03.2014 / 18:44

2 answers

3

If mysql_fetch_array is returning false , it is because there is no data in your table. Be sure to enter the data before doing SELECT .

    
04.03.2014 / 19:19
1

If you do not pass the connection identifier obtained earlier with the mysql_connect function, PHP will connect to a given default database in the PHP configuration (or not) when using mysql_query, but that connection may not have been established because the MySQL server address is not well configured.

It is not recommended not to pass connection identifier parameter because of this.

    
05.03.2014 / 07:36