I have a table, called tablelist filled with unique values in two columns - content and tablename and I want to select the tablename that corresponds to the content.
I have a short piece of code which gives the following error:
Warning: Supplied argument is not a valid MySQL result resource
...connect to database etc here...
$content = "question";
$sql= "SELECT * FROM tablelist WHERE content = $content";
$result = mysql_query($sql);
while ($myrow = mysql_fetch_array($result))
{
$tablename = $myrow["tablename"];
echo " <p> table name is $tablename </p>";
}
the table looks like this:
content tablename
question BobQ
news News
activity Activity
newscomment NewsC
activitycomment ActivityC
contacts Contacts
answer BobA
idea Idea
you can see it failing in action if you hit the submit button on this page:
http://playworktrainers.org.uk/bobA.php4
there is also a stray < but I'll worry about that when I've sorted this bit out