mysql_fetch_array not valid mysql result
Hey,
I have a problem:
I have this code in my website:
PHP Code:
<?php
$jaar = $_GET["jaar"];
echo "<div id='header'>Vriendengroep Oerdegelijk | ".$jaar."</div>";
echo "<div id='main'>";
mysql_connect("fdb3.agilityhoster.com","784975_years","oerdegelijk");
mysql_select_db("784975_years");
$sql = mysql_query("SELECHT * FROM jaren
WHERE jaar=$jaar");
$result = mysql_query("SELECT count(*) as bestaat FROM jaren WHERE jaar=$jaar");
$rij = mysql_fetch_assoc($result);
if($rij['bestaat'] != 1){
echo "Over het jaar ".$jaar." is nog geen informatie beschikbaar.";
} else {
while($row = mysql_fetch_array($sql)){
echo "Datum: ".$row['datum'];
}
}
echo "</div>";
?>
What I want the code to do is to check in the database if there's a row with the year(jaar) as the variable $jaar, when it does it has to
PHP Code:
echo "Over het jaar ".$jaar." is nog geen informatie beschikbaar.";
and else it has to give the date that's in the same row as the year.
But I continue getting this error:
Code:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /srv/disk7/784975/www/oerdegelijk.agilityhoster.com/jaren.html on line 33
Can anyone explain me what I'm doing wrong, and give the solution?
p.s. I'm dutch, so when you need any translations, just say.