I’m trying to connect to a database that I created using this code:
<?php
function Conectarse()
{
$host="localhost";
$user="root";
$password="root";
$bda="toobebe_catalogo";
if (!($link=mysql_connect($host,$user,$password)))
{
echo "Error conectando a la base de datos.<br>";
exit();
}
else
{
echo "Éxito conectando con la base de datos.<br>";
}
if (!mysql_select_db($bda,$link))
{
echo "Error seleccionando la base de datos.<br>";
exit();
}
else
{
echo "Éxito al encontrar la base de datos.<br>";
}
return $link;
}
$conn=Conectarse();
$sql="SELECT * FROM toobebe-octubre";
$db_fila = mysql_query($sql,$conn);
$ok=1;
while (($row = mysql_fetch_array($db_fila)) && $ok)
{
$valor=mysql_query($sql,$conn);
if(!$valor)
{
$ok=0;
}
}
?>
But it fires this mistake when I execute it:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in ...
I’ve been searching, and to know:
– Database exists
-
Permissions are correct
-
Table exists
-
Table is not null
Any idea on why this mistake is happening?
EDIT:
Added image with the mistake:

The error isn’t with connecting to the Database, but rather with your query. You have a hyphen in your table name, so you should try and enclose it as follows:
Just a couple of tips, using
mysql_*is severely deprecated now. You should really be usingmysqli_*at a very minimum, or PDO.Also,
SELECT *is generally considered a bad practice, because I really doubt you do need everything from the table.