mysql_fetch_assoc(): supplied argument is not a valid MySQ
Posted: Sat Nov 21, 2009 12:19 pm
Please help. I am getting error message mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource
I have tested my connection and it works
I am getting result from echo $result
What I'm i doing wrong?
<?php
$con = mysql_connect("local","password","user");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
if (!mysql_select_db("dbname", $con)) {
exit('<p>Unable to connect');
}
$result = mysql_query ("SELECT id, title, description FROM dir_categories ");
if (!$result) {
echo 'no, no ';
}
echo $result;
$answer = mysql_query ($result);
while ($row = mysql_fetch_assoc ($answer)) {
echo '<title>'.htmlentities($row['title']).'</title>';
echo '<description>'.htmlentities($row['description']).'</description>';
}
mysql_close($con);
?>
I have tested my connection and it works
I am getting result from echo $result
What I'm i doing wrong?
<?php
$con = mysql_connect("local","password","user");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
if (!mysql_select_db("dbname", $con)) {
exit('<p>Unable to connect');
}
$result = mysql_query ("SELECT id, title, description FROM dir_categories ");
if (!$result) {
echo 'no, no ';
}
echo $result;
$answer = mysql_query ($result);
while ($row = mysql_fetch_assoc ($answer)) {
echo '<title>'.htmlentities($row['title']).'</title>';
echo '<description>'.htmlentities($row['description']).'</description>';
}
mysql_close($con);
?>