PHP gevorderde |
|
<?
if ($_FILES['bestand']) {
//************* te editeren *******************
//tabeldinges
$tabelnaam = "tacx"; //naam van de tabel
$origineelveld = "origineel"; //naam van de velden in je tabel
$uniekveld = "uniek"; //naam van de velden in je tabel
$mimeveld = "mime"; //naam van de velden in je tabel
//volgende var is het pad waar alles wordt opgeslagen.
$eindlocatie = $_SERVER['DOC_ROOT']."/var/www/html/Chris/files/tacx/"; //echo deze
$result = mysql_query("SELECT * FROM ".$tabelnaam." WHERE user='".$_SESSION['dbid']."' AND league='longvrbar' AND Round='" . $Round . "' AND Dy='".$Dy."' ");
$count = mysql_num_rows($result);
//is er nog geen cijfer gegeven
if ($count == 0)
{
$uniekenaam = longvrbar.$Dy.'_'.$Round.'_'.$_SESSION['dbid'];
$bestandsnaam = str_replace("\'","\\'",$_FILES['bestand']['name']);
if ( move_uploaded_file($_FILES['bestand']['tmp_name'], $eindlocatie.$uniekenaam) )
{
$m=1.6093;
$mph = $kph/$m;
$Roundx = longvrbar.$Round;
$queryzin = "INSERT INTO ".$tabelnaam." (".$uniekveld.", ".$origineelveld.", ".$mimeveld.",user,Dd,Dm,Dy,Th,Tm,Ts,Round,kph,mph,league) VALUES ('".addslashes($uniekenaam)."', '".addslashes($_FILES['bestand']['name'])."','".addslashes($_FILES['bestand']['type'])."','".$_SESSION['dbid']."','" . $Dd . "','" . $Dm . "','" . $Dy . "','" . $Th . "','" . $Tm . "','" . $Ts . "','" . $Roundx . "','".$kph."','".$mph."','longvrbar')";
mysql_query($queryzin) or die(mysql_error());
$result2 = mysql_query("SELECT * FROM vrbar WHERE userid='".$_SESSION['dbid']."' AND bar='long'");
$count2 = mysql_num_rows($result2);
//is er nog geen cijfer gegeven
if ($count2 == 0)
{
echo $queryzin5 = "INSERT INTO vrbar (naam,userid,bar,".$Round.") VALUES ('".$_SESSION['naam']."','".$_SESSION['dbid']."','long','1')";
mysql_query($queryzin5) or die(mysql_error());
}
elseif ($count2 == 1)
{
echo $queryzin6 = "UPDATE vrbar SET ".$Round."='1' WHERE userid='".$_SESSION['dbid']."' AND bar='long'";
mysql_query($queryzin6) or die(mysql_error());
}
echo "<br><div align=\"center\"><B><font size=\"2\" face=\"Verdana\">You've add your result!</font></B><br></div>";
echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"1;URL=index.php?id=memberarea\">";
}
}
elseif ($count == 1)
{
$uniekenaam = longvrbar.$Dy.'_'.$Round.'_'.$_SESSION['dbid'];
$bestandsnaam = str_replace("\'","\\'",$_FILES['bestand']['name']);
if ( move_uploaded_file($_FILES['bestand']['tmp_name'], $eindlocatie.$uniekenaam) )
{
$m=1.6093;
$mph1 = $kph/$m;
$Roundx = longvrbar.$Round;
$queryzin = "UPDATE ".$tabelnaam." SET ".$uniekveld."='".addslashes($uniekenaam)."', ".$origineelveld."='".addslashes($_FILES['bestand']['name'])."', ".$mimeveld."='".addslashes($_FILES['bestand']['type'])."', user='".$_SESSION['dbid']."', Dd='" . $Dd . "', Dm='" . $Dm . "', Dy='" . $Dy . "', Th='" . $Th . "', Tm='" . $Tm . "', Ts='" . $Ts . "', Round='" . $Roundx . "', mph='".$mph1."', kph='".$kph."' WHERE user='".$_SESSION['dbid']."' AND Round='" . $Round . "'";
mysql_query($queryzin) or die(mysql_error($queryzin));
$cQuery = mysql_query("SELECT AVG(`mph`) FROM `tacx` WHERE league='longvrbar' AND user=''".$_SESSION['dbid']."'");
$cAverage = mysql_result($cQuery,0);
echo $queryzin7 = "UPDATE vrbar SET avespeed='".round($cAverage,2)."' WHERE userid='".$_SESSION['dbid']."' AND bar='long'";
mysql_query($queryzin7) or die(mysql_error());
}
else
{
//gn transport
echo "<font color=red>geen transport</font><br>";
}
}
}
?>
<? if ($_FILES['bestand']) { //************* te editeren ******************* //tabeldinges $tabelnaam = "tacx"; //naam van de tabel $origineelveld = "origineel"; //naam van de velden in je tabel $uniekveld = "uniek"; //naam van de velden in je tabel $mimeveld = "mime"; //naam van de velden in je tabel //volgende var is het pad waar alles wordt opgeslagen. $eindlocatie = $_SERVER['DOC_ROOT']."/var/www/html/Chris/files/tacx/"; //echo deze $result = mysql_query("SELECT * FROM ".$tabelnaam." WHERE user='".$_SESSION['dbid']."' AND league='longvrbar' AND Round='" . $Round . "' AND Dy='".$Dy."' "); //is er nog geen cijfer gegeven if ($count == 0) { $uniekenaam = longvrbar.$Dy.'_'.$Round.'_'.$_SESSION['dbid']; $bestandsnaam = str_replace("\'","\\'",$_FILES['bestand']['name']); { $m=1.6093; $mph = $kph/$m; $Roundx = longvrbar.$Round; $queryzin = "INSERT INTO ".$tabelnaam." (".$uniekveld.", ".$origineelveld.", ".$mimeveld.",user,Dd,Dm,Dy,Th,Tm,Ts,Round,kph,mph,league) VALUES ('".addslashes($uniekenaam)."', '".addslashes($_FILES['bestand']['name'])."','".addslashes($_FILES['bestand']['type'])."','".$_SESSION['dbid']."','" . $Dd . "','" . $Dm . "','" . $Dy . "','" . $Th . "','" . $Tm . "','" . $Ts . "','" . $Roundx . "','".$kph."','".$mph."','longvrbar')"; $result2 = mysql_query("SELECT * FROM vrbar WHERE userid='".$_SESSION['dbid']."' AND bar='long'"); //is er nog geen cijfer gegeven if ($count2 == 0) { echo $queryzin5 = "INSERT INTO vrbar (naam,userid,bar,".$Round.") VALUES ('".$_SESSION['naam']."','".$_SESSION['dbid']."','long','1')"; } elseif ($count2 == 1) { echo $queryzin6 = "UPDATE vrbar SET ".$Round."='1' WHERE userid='".$_SESSION['dbid']."' AND bar='long'"; } echo "<br><div align=\"center\"><B><font size=\"2\" face=\"Verdana\">You've add your result!</font></B><br></div>"; echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"1;URL=index.php?id=memberarea\">"; } } elseif ($count == 1) { $uniekenaam = longvrbar.$Dy.'_'.$Round.'_'.$_SESSION['dbid']; $bestandsnaam = str_replace("\'","\\'",$_FILES['bestand']['name']); { $m=1.6093; $mph1 = $kph/$m; $Roundx = longvrbar.$Round; $queryzin = "UPDATE ".$tabelnaam." SET ".$uniekveld."='".addslashes($uniekenaam)."', ".$origineelveld."='".addslashes($_FILES['bestand']['name'])."', ".$mimeveld."='".addslashes($_FILES['bestand']['type'])."', user='".$_SESSION['dbid']."', Dd='" . $Dd . "', Dm='" . $Dm . "', Dy='" . $Dy . "', Th='" . $Th . "', Tm='" . $Tm . "', Ts='" . $Ts . "', Round='" . $Roundx . "', mph='".$mph1."', kph='".$kph."' WHERE user='".$_SESSION['dbid']."' AND Round='" . $Round . "'"; $cQuery = mysql_query("SELECT AVG(`mph`) FROM `tacx` WHERE league='longvrbar' AND user=''".$_SESSION['dbid']."'"); echo $queryzin7 = "UPDATE vrbar SET avespeed='".round($cAverage,2)."' WHERE userid='".$_SESSION['dbid']."' AND bar='long'"; } else { //gn transport echo "<font color=red>geen transport</font><br>"; } } } ?>
Vraagje: bewerking 'result=2' wordt toch alleen uitgevoert als 'result' nul opleverd?
Hij voerd nu altijd het script uit dat bij 0 hoort, ook als het geen 0 is
|