Avatar billede proff Nybegynder
22. december 2004 - 21:20 Der er 15 kommentarer og
1 løsning

Fejl i min elseif?

elseif($_POST[formation]!= "3-4-3" OR $_POST[formation]!= "3-3-4" OR $_POST[formation]!= "3-5-2" OR $_POST[formation]!= "4-4-2" OR $_POST[formation]!= "4-3-3" OR $_POST[formation]!= "4-2-4 OR" $_POST[formation]!= "2-4-4" OR $_POST[formation]!= "2-5-3") {
print "<ul><li><B>Ugyldig formation</B></ul></li>";

Jeg kan ikke se fejlen, jeg håber i kan ;o)

Parse error: parse error, unexpected T_VARIABLE in
Avatar billede sunepopp Nybegynder
22. december 2004 - 21:27 #1
prøv evt at sætte parenteser om betingelserne ( ($_POST[.........) OR ($_POST[]...) )

og sæt den afsluttende krøllede parentes (hvis den altså ikke er længere nede i din kode ;)
Avatar billede proff Nybegynder
22. december 2004 - 21:31 #2
elseif($_POST[formation]!= "3-4-3") OR ($_POST[formation]!= "3-3-4") OR ($_POST[formation]!= "3-5-2") OR ($_POST[formation]!= "4-4-2") OR ($_POST[formation]!= "4-3-3") OR ($_POST[formation]!= "4-2-4") OR ($_POST[formation]!= "2-4-4") OR ($_POST[formation]!= "2-5-3") {


Virker stadig ikke. Dog har jeg fået en ny fejl:
Parse error: parse error, unexpected T_LOGICAL_OR in
Avatar billede sunepopp Nybegynder
22. december 2004 - 21:36 #3
der mangler vist også lige en enkelt start parentes aller forret og tilsidst:

elseif( ($_POST[formation]!= "3-4-3") OR ($_POST[formation]!= "3-3-4") OR ($_POST[formation]!= "3-5-2") OR ($_POST[formation]!= "4-4-2") OR ($_POST[formation]!= "4-3-3") OR ($_POST[formation]!= "4-2-4") OR ($_POST[formation]!= "2-4-4") OR ($_POST[formation]!= "2-5-3") ) {
Avatar billede proff Nybegynder
22. december 2004 - 21:48 #4
Nu får jeg dog ingen fejl. Men alligevel ;)


elseif(($_POST[formation]!= "3-4-3") OR ($_POST[formation]!= "3-3-4") OR ($_POST[formation]!= "3-5-2") OR ($_POST[formation]!= "4-4-2") OR ($_POST[formation]!= "4-3-3") OR ($_POST[formation]!= "4-2-4") OR ($_POST[formation]!= "2-4-4") OR ($_POST[formation]!= "2-5-3")) {
print "<ul><li><B>Ugyldig formation $_POST[formation]</B></ul></li>";

Den skriver: Ugyldig formation. Det skal den kun skrive hvis $_POST[formation] IKKE = en af de formationer der står deroppe. Hvis du forstår. Hvad har jeg lavet galt?
Avatar billede sunepopp Nybegynder
22. december 2004 - 21:51 #5
du skal skrive det i anførselstegn:  $_POST["formation"] :)
Avatar billede proff Nybegynder
22. december 2004 - 21:55 #6
Det er gjort nu. Jeg får stadig bare fejlen. Ugyldig formation.
Jeg kan printe min formation når den skriver ugyldig formation. Det er det samme som der står i min elseif. Altså ved jeg ikke hvad der er galt !-)

Den ved hvad formationen er. Mit eneste bud kunne være jeg ikke har lavet min elseif korrekt
Avatar billede proff Nybegynder
22. december 2004 - 21:55 #7
!= <- Er dette den korrekt betegnelse for hvis det IKKE er?
Avatar billede sunepopp Nybegynder
22. december 2004 - 22:01 #8
hmm... jo "!=" er skam god nok. prøv at sende hvordan koden ser ud nu
Avatar billede proff Nybegynder
22. december 2004 - 22:02 #9
<?php
include "sql.php";
if(!isset($_SESSION["email"])) {
die("Du skal være logget ind for at bruge denne funktion!");
}
include "config.php";
if($function == "1") {
$hold = mysql_query("SELECT id,klub,formation FROM users WHERE email='$_SESSION[email]'") or die(mysql_error());
$row_hold = mysql_fetch_array($hold);
if($row_hold[formation] == "3-4-3") {
$img = "../gfx/formation/formation343.gif";
} elseif($row_hold[formation] == "3-3-4") {
$img = "../gfx/formation/formation334.gif";
} elseif($row_hold[formation] == "3-5-2") {
$img = "../gfx/formation/formation352.gif";
} elseif($row_hold[formation] == "4-4-2") {
$img = "../gfx/formation/formation442.gif";
} elseif($row_hold[formation] == "4-3-3") {
$img = "../gfx/formation/formation433.gif";
} elseif($row_hold[formation] == "4-2-4") {
$img = "../gfx/formation/formation424.gif";
} elseif($row_hold[formation] == "2-4-4") {
$img = "../gfx/formation/formation244.gif";
} elseif($row_hold[formation] == "2-5-3") {
$img = "../gfx/formation/formation253.gif";
}

print "
<form action=\"formation.php?updatefunction=1\" method=\"POST\">
<table border=\"0\" width=\"100%\" height=\"362\">
  <tr>
    <td width=\"37%\" height=\"358\"><img border=\"0\" src=\"$img\" id=\"preview\" width=\"320\" height=\"415\"></td>
    <td width=\"63%%\" valign=\"top\" height=\"358\">
      <table border=\"0\" width=\"100%\">
        <tr>
          <td width=\"100%\" style=\"border: 1px solid black\">
            <table border=\"0\" width=\"100%\">
        <tr>
          <td width=\"20\" align=\"center\"><input type=\"radio\" value=\"3-4-3\" checked name=\"formation\" onclick=\"document.getElementById('preview').src='../gfx/formation/formation343.gif'\"></td>
          <td width=\"44%\"><B>3-4-3</B></td>
          <td width=\"6%\" align=\"center\"><input type=\"radio\" value=\"4-3-3\" name=\"formation\" onclick=\"document.getElementById('preview').src='../gfx/formation/formation433.gif'\"></input></td>
          <td width=\"44%\"><B>4-3-3</B></td>
        </tr>
        <tr>
          <td width=\"20\" align=\"center\"><input type=\"radio\" value=\"3-3-4\" name=\"formation\" onclick=\"document.getElementById('preview').src='../gfx/formation/formation334.gif'\"></input></td>
          <td width=\"44%\"><B>3-3-4</B></td>
          <td width=\"6%\" align=\"center\"><input type=\"radio\" value=\"4-2-4\" name=\"formation\" onclick=\"document.getElementById('preview').src='../gfx/formation/formation424.gif'\"></input></td>
          <td width=\"44%\"><B>4-2-4</B></td>
        </tr>
        <tr>
          <td width=\"20\" align=\"center\"><input type=\"radio\" value=\"3-5-2\" name=\"formation\" onclick=\"document.getElementById('preview').src='../gfx/formation/formation352.gif'\"></input></td>
          <td width=\"44%\"><B>3-5-2</B></td>
          <td width=\"6%\" align=\"center\"><input type=\"radio\" value=\"2-4-4\" name=\"formation\" onclick=\"document.getElementById('preview').src='../gfx/formation/formation244.gif'\"></input></td>
          <td width=\"44%\"><B>2-4-4</B></td>
        </tr>
        <tr>
          <td width=\"20\" align=\"center\"><input type=\"radio\" value=\"4-4-2\" name=\"formation\" onclick=\"document.getElementById('preview').src='../gfx/formation/formation442.gif'\"></input></td>
          <td width=\"44%\"><B>4-4-2</B></td>
          <td width=\"6%\" align=\"center\"><input type=\"radio\" value=\"2-5-3\" name=\"formation\" onclick=\"document.getElementById('preview').src='../gfx/formation/formation253.gif'\"></input></td>
          <td width=\"44%\"><B>2-5-3</B></td>
        </tr>
        <tr>
    <td width=\"100%\" colspan=\"4\"><input type=\"image\" img onMouseDown=\"this.filters.alpha.opacity=65\" onMouseOver=\"this.filters.alpha.opacity=65\" style=\"FILTER: alpha(opacity=100)\" onMouseOut=\"this.filters.alpha.opacity=100\" src=\"../gfx/submit_off.gif\" border=\"0\" width=\"46\" height=\"17\"></td>
        </tr>
      </table>
      </td>
      </tr>
    </table>
    </td>
  </tr>
</table>
</form>";
}
if($updatefunction == "1") {
if($_POST[formation] =="") {
print "<ul><li>Du har ikke valgt nogen formation</ul></li>";
}
elseif(($_POST["formation"]!= "3-4-3") OR ($_POST["formation"]!= "3-3-4") OR ($_POST["formation"]!= "3-5-2") OR ($_POST["formation"]!= "4-4-2") OR ($_POST["formation"]!= "4-3-3") OR ($_POST["formation"]!= "4-2-4") OR ($_POST["formation"]!= "2-4-4") OR ($_POST["formation"]!= "2-5-3")) {
print "<ul><li><B>Ugyldig formation $_POST[formation]</B></ul></li>";
} else {
print "Alt ok";
}
}
?>
Avatar billede sunepopp Nybegynder
22. december 2004 - 22:08 #10
hmm.. den ser nu umiddelbart god nok ud, men sæt evt også anførsels tegn om formation i if sætningen lidt længere oppe:
if($_POST[formation] =="") {
Avatar billede proff Nybegynder
22. december 2004 - 22:14 #11
Det har jeg så gjort nu. Men fejlen er der stadig: Ugyldig formation
Avatar billede proff Nybegynder
22. december 2004 - 22:20 #12
Og den giver nøjagtig samme fejl her:

elseif($_POST["formation"]!= "3-4-3" OR "3-3-4" OR "3-5-2" OR "4-4-2" OR "4-3-3" OR "4-2-4" OR "2-4-4" OR "2-5-3") {
print "<ul><li><B>Ugyldig formation $_POST[formation]</B></ul></li>";

- Jeg giver op :(
Avatar billede sunepopp Nybegynder
22. december 2004 - 22:23 #13
som det er nu bliver elseif sætningen sand (den skriver "ugyldig formation"), hvis der ER krydset af en bare én af formationerne der undersøges på. (eks. 3-4-3, 3-3-4..). Er det meningen?
Avatar billede proff Nybegynder
22. december 2004 - 22:25 #14
Ja, det er meningen. Det er hvis formationen man har valgt er anderledes end de formationer der den skal give forkert formation
Avatar billede sunepopp Nybegynder
22. december 2004 - 22:48 #15
jeg er bange for jeg også må melde pas... men kommer til at tænke på at variablen "formation" nok skal være et array man søger igennem element for element for at se og det er lig med en af de ugyldige formationer..
Avatar billede proff Nybegynder
08. april 2007 - 13:32 #16
Lukning forsinket en årrække .-)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester



IT-JOB

Cognizant Technology Solutions Denmark ApS

Senior Delivery Manager

Netcompany A/S

Software Developer