Wrong switch statement please help fix it

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Wrong switch statement please help fix it

    Hello guys i've coded a death calculator but it looks like some is wrong with my month switch statement here's the code
    PHP Code:
    <?php
    echo '<html>
            <head>
              <title>jnrWap.co.cc | Death calculator results</title>
              <link rel="stylesheet" type="text/css" href="../downloads/style.css"/>
              </head>
            <body>
          <div class="title"><img src="../logo.png" alt="jnrWap"/></div>'
    ;
    $fname $_POST['fname'];
    $dd    $_POST['dd'];
    $mm    $_POST['mm'];
    $yy    $_POST['yy'];
    $sname $_POST['sname'];
    $city  $_POST['city'];
    $place $_POST['place'];
    $yr    date("Y");
    $yr1   date("Y") + 1;
      echo 
    '<div class="dl">';
    include(
    "../admob.php");
      echo 
    '</div><div class="dl2">';
     if(
    $dd 31 || $mm 12 || $yy $yr)
      {
        echo 
    'You entered a wrong Date of birth <a href="index.php">start again</a><br>';
      }
     else 
        {
           echo 
    $fname.' '.$sname.' Will die on this day ';
           
    $dday  rand(1,28);
      
           echo 
    $dday.' ';
    /*Problem must be somewhere around here, instead of getting a month displayed i get a month and a number like 14 March3 2014 instead of 14 March 2014
    */
            
    $dmnth rand(1,12);

            switch(
    $dmnth)
     {
     case 
    : echo 'January';
      break;
     case 
    : echo 'February';
      break;
     case 
    : echo 'March';
      break;
     case 
    : echo 'April';
      break;
     case 
    : echo 'May';
      break;
     case 
    : echo 'June';
      break;
     case 
    : echo 'July';
      break;
     case 
    : echo 'August';
      break;
     case 
    : echo 'September';
      break;
     case 
    10 : echo 'October';
      break;
     case 
    11 : echo 'November';
      break;
     default : echo 
    'December';
      break;


     echo 
    $dmnth.' ';
    $dyp   $yr 20;
    $dyr   rand($yr1,$dyp);
     
    echo 
    $dyr.' I\'m sorry to break the news<br><div class="dl">';
    }
    include(
    "../buzz.php");
      echo 
    '</div>';
    include(
    "../foot.php");
    ?>
    Oh and if you want a demo please go to jnrWap
    libra.wen.ru

    #2
    Your switch statement is correct.
    The problem is the echo $dmnth. After the switch. You echoed the month already in the switch. You did not reassign the dmnth var so echoing it echoes the month number as well.

    New code
    PHP Code:
    e c h o  ' ' ;//remove $dmnth
    d y p = $ y r 2 0 ;
    d y r r a n d ( $ y r 1 ,
    d y p ) ; 
    Last edited by frostymarvelous; 15.02.11, 09:05.
    Perfection comes at a cost



    I accept liberty!

    Comment


      #3
      Thanks frostymarvelous it worked and i had more than one error and i fixed them all now
      libra.wen.ru

      Comment


        #4
        You welcome bro. Btw, you could use a simple mktime and date function to replace your switch statements.
        Little by little, you will get there.
        Perfection comes at a cost



        I accept liberty!

        Comment

        Working...
        X