Maybe a silly question but it's killing me...
When I get results from a database within a function in a class, and I return that result within that function. When I include that class into my main page and get the return value of the function i'm calling it's no result from the database no more but a boolean.
I get this error message:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\wezzel\Framework\php\database.php on line 24
This is the function from database.php:
function getQuery($sql)
{
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$con = connectDatabase();
mysql_select_db("joetsy", $con);
$result = mysql_query($sql);
disconnectDatabase($con);
return mysql_fetch_array($result);
mysql_close($con);
}
This is the thing i'm trying to do in the main page index.php:
include_once('php\database.php');
$result = getQuery("SELECT * FROM binks.bink");
while($row = $result)
{
echo("
<li class='store'>
<a href='bink.php?id=" . $row['binkid'] . "'>Bink</a>
</li>
");
}