Hey
I have this problem with me php code, I have no idea what the problem is, so I was hoping you guys could help me out.
Here's the code
PHP Code:
<html>
<head>
<title>Lab 4</title>
</head>
<body>
<?
$connection = mysql_connect("xxx", "xxx", "xxx") or die ("Kunde inte an****a!");
mysql_select_db("xxx", $connection);
$input = $_POST['revealThis'];
if ($input == debattartiklar)
$sql = "SELECT * FROM debatt";
else if($input == eva)
$sql = "SELECT * FROM debatt, sports WHERE forfattare='Eva Svensson'";
else
echo "Du valde inget alternativ, vänligen välj ett";
$result = mysql_query($sql, $connection);
while ($myRow = mysql_fetch_array($result)) {
echo "<h3 style=\"lineheight:1.5em;margin:0;padding:0;\">" . $myRow['rubrik'] . "</h3>";
echo "<strong>" . $myRow['ingress'] . "</strong><br />";
echo $myRow['brodtext'] . "<br />";
echo $myRow['forfattare'] . ", " . $myRow['datum'] . "<br /><br />";
}
mysql_close($connection);
?>
</body>
</html>
And this is the error i get:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in D:\FTPROOT\KTD\sh09hf1763\www\webbapplikationer09\ lab4\lab.php on line 23
Here's the script in action if you want to have a look at it. The input-radio-option that does not work is the second one, the first works perfectly.
http://student.ktd.sh.se/~sh09hf1763...lab4/form.html
Thanks alot!
EDIT: I realized you can't fetch something from a table where the fetch-item does not exist. However, I now have no idea how I'm going to make it possible to search all tables for posts by the author "Eva Svensson"