I have my codes which gives me the following eror,
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\jopasy_community_2.2\includes\view.php on line 28
Below are the codes
<?php
include 'connection.php';
$con = mysql_connect($host,$user,$pwd);
$db = mysql_select_db($database);
include 'create_tables.php';
$sql = 'SELECT name, qntitle, question FROM questions';
$retval = mysql_query( $sql, $con );
if(! $retval )
{
die('Could not get data: ' . mysql_error());
}
while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
{
$qnabout=$row['qntitle'];
echo "<b>Question: </b>{$row['question']} <br>".
"<b>Asked by : </b> {$row['name']} <br> ".
"<b>Question about: </b> {$row['qntitle']} <br><br> ".
"<b>Answers</b> <br><br> ".
$getanswer = ("SELECT answerdby, answer FROM answers WHERE qntitle ='".$qnabout."';");
$answer = mysql_query( $getanswer, $con );
while($ans = mysql_fetch_array($answer, MYSQL_ASSOC)) //This is the line witherror
{
echo "Answer : {$ans['answer']} <br> ".
"<b>Answered by : </b> {$ans['answerdby']} <br> ".
"--------------------------------<br><br><br><hr>";
}
}
mysql_close($con);
?>