Problem with a switch statement

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Francisco Mendez

    Problem with a switch statement

    I have the following problem:

    When i use "scooters" in the value of the radio as well as in the switch
    statement, the code doesn't get executed, but if i use "scooter" it does.
    Is there something wrong with my code?

    Thanks
    FM>
    --------------------------
    Code is as follows:

    <?php
    fuction vehicles($selec tion)
    {

    ....
    ....

    echo $selection;
    }
    ?>

    ....
    ....

    <form method="get" action="select. php">

    <table align="center" width="70%" border="1" cellspacing="2"
    cellpadding="2" >
    <tbody>
    <tr>
    <td width="100%" colspan="3" align="center"> Select a Vehicle </td>
    </tr>
    <tr>
    <td width="25%"><br ><input type="radio" name="vehicle"
    value="scooters ">Motos / Scooters </td>
    <td width="25%"><br ><input type="radio" name="vehicle"
    value="cars">Au tos / Cars </td>
    <td width="25%"><br ><input type="submit" value="Seleccio nar"> </td>

    </tr>

    <?php

    $selection = clean($_GET["vehicle"], 7);

    if (!empty($select ion))
    {
    switch ($selection)
    {
    case "scooters":
    echo "<tr><td>";
    vehicles($selec tion);
    $selected_type = $selection;
    echo "</td><td></td><td>" . $selected_type .
    "</td></tr></tbody></table>";
    break;

    case "cars":
    echo "<tr><td></td><td>";
    vehicles($selec tion);
    $selected_type = $selection;
    echo "</td><td>" . $selected_type . "</td></tr></tbody></table>";
    break;
    } //End switch

    /* Set $selection to empty for the case the user made a mistake
    ** and wnts to select other type of vehicle
    */

    $selection ="";

    } // End if

    ?>

    </tbody>
    </table>
    </form>

  • Francisco Mendez

    #2
    Re: Problem with a switch statement

    sorry it was all in the clean function.

    thx

    FM>

    Comment

    Working...