Hi all!
I have some queries that lives to make my day more difficult... Take a look:
$sql = "SELECT * FROM `emkonk_tipping` WHERE `kamp`='$kamp'";
echo $sql; //debugging purpose
$result = mysql_query($sql) or die ("Error 2");
while ($res = mysql_fetch_array($result)) {
//lots of stuff here
}
This one gives me this error message:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in [...]/inc/admin.inc.php on line 65
When I echo the sql query it looks like this:
SELECT * FROM emkonk_tipping WHERE kamp='4'
The table emkonk_tipping contains these fields:
id tinyint(4)
brukernavn varchar(50)
kamp tinyint(4)
tipp tinyint(1)
Why do I get the error?
The other devil-query looks like this in context:
$tid = date("H");
$frist = 16;
if ($tid < $frist) {
$dato = date("j.m");
$sql = "SELECT * FROM `emkonk_kamper` WHERE `resultat`='0' AND `dato`='$dato'";
$result = mysql_query($sql) or die ("Error 3");
if (!(mysql_fetch_array($result))) {
echo "Ingen kamper registrert til dagens dato";
}
while ($res = mysql_fetch_array($result)) {
$i = 0;
$i++;
$id = $res['id'];
$lag1 = $res['lag1'];
$lag2 = $res['lag2'];
$dato = $res['dato'];
echo "<form name=\"form2".$i."\" method=\"post\" action=\"?s=hoved&op=tipp\">
<font face=\"Arial, Helvetica, sans-serif\" size=\"2\">
ID: ".$id." DATO: ".$dato."
<input type=\"radio\" name=\"resultat\" value=\"1\">".$lag1." - ".$lag2."
<input type=\"radio\" name=\"resultat\" value=\"2\">
<input type=\"submit\" name=\"regres\" value=\"Tipp!\">
<input type=\"hidden\" name=\"kamp\" value=\"".$id."\">
</font><br></form>";
}
}
Let's say I have 2 rows in the table emkonk_kamper. This code only shows the second row! If I have 3 rows, it only shows row 2 and 3! It never shows row 1 :queasy:
What can I do to fix this?