www.webdeveloper.com
Results 1 to 9 of 9

Thread: megamillion project

  1. #1
    Join Date
    Dec 2012
    Posts
    3

    megamillion project

    my project for school. was supposed to allow users to pick #s, make sure they cant pick # twice for white ball. quick play is a random play of #s, "draw" draws the winning #'s when not quick played(quick play and draw both draw random winning #'s that are compared to see prize $. please help its confusing :/. parse error line 13 which is "for ($i = 0; $i ! 6; $i++){" i just dont see where that could be... probably more errors than just that...

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/199/xhtml">

    <head>
    <title>MEGA MILLIONS</title>
    </head>
    <h1>WIN SOME CASH!</h1>
    <body>
    <?php
    function draw(){
    for ($i = 0; $i ! 6; $i++){
    switch ($i) {
    case 0:
    echo "<img src=\http://131.118.95.215/users/teschlauch0/Projects/White/\$array[0].jpg\" alt=\"1\"/>";
    break;
    case 1:
    echo "<img src=\http://131.118.95.215/users/teschlauch0/Projects/White/\$array[1].jpg\" alt=\"2\"/>";
    break;
    case 2:
    echo "<img src=\http://131.118.95.215/users/teschlauch0/Projects/White/\$array[2].jpg\" alt=\"3\"/>";
    break;
    case 3:
    echo "<img src=\http://131.118.95.215/users/teschlauch0/Projects/White/\$array[3].jpg\" alt=\"4\"/>";
    break;
    case 4:
    echo "<img src=\http://131.118.95.215/users/teschlauch0/Projects/White/\$array[4].jpg\" alt=\"5\"/>";

    default:
    break;}
    array[]++;
    }
    echo "http://131.118.95.215/users/teschlauch0/Projects/gold/\$yellow.jpg\" alt=\"5\"/>\n</ br>";
    }

    ?>
    <h2 style = "text-align:center">Pick five #s between 1-56 and one between 1-46</h2>
    <form name="megamillion" action="4-2.php" method="post">
    <fieldset>
    <p>1-56 <input type="text" name="white"
    value="white" /></p>
    <input type="submit" name="enter white" value="enter white"/>
    </fieldset>
    </form>
    <form name="submit" action="4-2.php" method="post">
    <fieldset>
    <p>1-46 <input type="text" name="yellow"
    value="yellow" /></p>
    <input type="submit" name="enter yellow" value="enter yellow"/>
    </fieldset>
    </form>
    <form>
    <fieldset>
    <input type="submit" name="quick play" value="quick play"/>
    </fieldset>
    <fieldset>
    <h2>When Done Hit Draw Below or for random #s quick play above</h2>
    <input type="submit" name="draw" value="draw"/>
    </fieldset>
    </form>
    <?php


    }
    $ShowForm = TRUE;

    $array[] = $_POST['white'];
    $yellow = $_POST['yellow'];
    session_start();
    if($_SESSION['white'] = $_SESSION['white'])
    echo "Cannot enter same # twice";
    else{
    draw($array[0],$yellow);
    }
    if ($_POST['quick\ play']){
    $yellow = rand(1, 46);
    $i2 = 1;
    while ($i2 ! 6){
    $array[] = rand(1, 56);
    $i2++;
    }
    draw($array[0],$yellow);
    $yellow2 = rand(1, 46);
    $i3 = 1
    while ($i3 ! 6){
    $array2[] = rand(1, 56);
    $i3++;
    }
    draw($array2[0],$yellow2);
    echo"</ br> <img src=\http://131.118.95.215/users/teschlauch0/Projects/White/\$array[0].jpg\>" .
    "<img src=\http://131.118.95.215/users/teschlauch0/Projects/White/\$array2[1].jpg\>" .
    "<img src=\http://131.118.95.215/users/teschlauch0/Projects/White/\$array2[2].jpg\>" .
    "<img src=\http://131.118.95.215/users/teschlauch0/Projects/White/\$array2[3].jpg\>" .
    "<img src=\http://131.118.95.215/users/teschlauch0/Projects/White/\$array2[4].jpg\>" .
    "<img src=\http://131.118.95.215/users/teschlauch0/Projects/gold/\$yellow2.jpg\>"
    }
    if ($_POST['draw']){
    $yellow2 = rand(1, 46);
    $i3 = 1
    while ($i3 ! 6){
    $array2[] = rand(1, 56);
    $i3++;
    }
    draw($array2[0],$yellow2);
    echo"</ br> <img src=\http://131.118.95.215/users/teschlauch0/Projects/White/\$array[0].jpg\>" .
    "<img src=\http://131.118.95.215/users/teschlauch0/Projects/White/\$array2[1].jpg\>" .
    "<img src=\http://131.118.95.215/users/teschlauch0/Projects/White/\$array2[2].jpg\>" .
    "<img src=\http://131.118.95.215/users/teschlauch0/Projects/White/\$array2[3].jpg\>" .
    "<img src=\http://131.118.95.215/users/teschlauch0/Projects/White/\$array2[4].jpg\>" .
    "<img src=\http://131.118.95.215/users/teschlauch0/Projects/gold/\$yellow2.jpg\>";
    }
    if ($yellow = $yellow2 & $array[1,2,3,4,5] ! $array2[1,2,3,4,5]){
    echo"</ br>Pay out 2 dollars";
    }
    if ($yellow = $yellow2 & $array[0] | $array2[0] XOR $array[1] | $array2[1] XOR $array[2] | $array2[2] XOR $array[3] | $array2[3] XOR $array[4] | $array2[4]){
    echo"</ br>3 bucks!";
    }
    if ($yellow ! $yellow2, if ($array[0] = $array2[0], $i++)($array[1] = $array2[1], $i++) ($array[2] = $array2[2], $i++) ($array[3] = $array2[3], $i++) ($array[4] = $array2[4],$i++)){
    if ($i == 3){
    echo"</ br>7 dollars nice play!";
    }
    }
    if ($yellow = $yellow2, if ($array[0] = $array2[0], $i++) ($array[1] = $array2[1], $i++) ($array[2] = $array2[2], $i++ ($array[3] = $array2[3], $i++) ($array[4] = $array2[4],$i++){
    if ($i == 2){
    echo"</ br>10 dollars good win!!!";
    }
    }
    if ($yellow = $yellow2, if ($array[0] = $array2[0], $i++)($array[1] = $array2[1], $i++) ($array[2] = $array2[2], $i++) ($array[3] = $array2[3], $i++) ($array[4] = $array2[4],$i++)){
    if ($i == 3){
    echo"</ br>150\$!!! dont spend it all in one place.";
    }
    }
    if ($yellow ! $yellow2, if ($array[0] = $array2[0], $i++) ($array[1] = $array2[1], $i++) ($array[2] = $array2[2], $i++ ($array[3] = $array2[3], $i++) ($array[4] = $array2[4],$i++){
    if ($i == 4){
    echo"</ br>150\$!!! dont spend it all in one place.";
    }
    }
    if ($yellow = $yellow2, if ($array[0] = $array2[0], $i++)($array[1] = $array2[1], $i++) ($array[2] = $array2[2], $i++) ($array[3] = $array2[3], $i++) ($array[4] = $array2[4],$i++)){
    if ($i == 4){
    echo"</ br>10 grand time for a new car !!!!!";
    }
    }
    if ($yellow ! $yellow2, if ($array[0] = $array2[0], $i++) ($array[1] = $array2[1], $i++) ($array[2] = $array2[2], $i++ ($array[3] = $array2[3], $i++) ($array[4] = $array2[4],$i++){
    if ($i == 5){
    echo"</ br>250,000 in this market oyu might as well be a millionaire";
    }
    }
    if ($yellow = $yellow2, if ($array[0] = $array2[0], $i++)($array[1] = $array2[1], $i++) ($array[2] = $array2[2], $i++) ($array[3] = $array2[3], $i++) ($array[4] = $array2[4],$i++)){
    if ($i == 5){
    echo"</ br></ br>!!!!!!!!!!!!!!!!JACKPOT WINNER!!!!!!!!!!!!!!!!!";
    ?>
    </body>

    </html>

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,176
    If you post your code here within [php]...[/php] bbcode tags, it will be much easier for us to read.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,176
    ! is not a PHP operator. (I suspect you meant != ?)
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,176
    Quote Originally Posted by NogDog View Post
    ! is not a PHP operator. (I suspect you meant != ?)
    PS: The "!" character is a logical operator, but it's not a comparison operator.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  5. #5
    Join Date
    Oct 2010
    Location
    Ohio
    Posts
    233
    Nog did you really just reply to yourself? that's great.
    ~Ryan
    www.rdennispallas.com <-- Personal Site, changing regularly cuz its ugly.

  6. #6
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,176
    Quote Originally Posted by Derokorian View Post
    Nog did you really just reply to yourself? that's great.
    Yeah, no moderator powers here, and I couldn't edit my post by the time I realized I sort of misspoke.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  7. #7
    Join Date
    Dec 2012
    Posts
    3
    thanks for the input. I'll try to figure out that bbcode tag thing

  8. #8
    Join Date
    Dec 2012
    Posts
    3
    now i just got parse errors for all the prize winnings at the end i am not sure how to use the index to count the amount of white balls. hopefully i'll figure it out

  9. #9
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,176
    One hint (or 2): "=" (assignment operator) is very different than "==" (comparison operator). Also, "&" (bitwise 'and' operator) is different than the "&&" (logical "and" operator). The first two ("=" and "==") trip up even experienced coders from time to time with difficult to find bugs.

    Also, you might find it easier to get the number of matches by putting the user's selections into one array, and the numbers drawn into another array, then use array_intersect() to get an array of matching numbers, which you can the process with count() to get the number of matches, e.g.:
    PHP Code:
    <?php

    $userPicks 
    = array(1,3,5,7,9);
    $actualNumbers = array(1,4,7,11,12);
    $numMatches array_intersect($userPicks$actualNumbers);
    echo 
    "User matched " count($numMatches) . " numbers";
    Then you would not have to mess around with those convoluted if() statements.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles