Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2007
    Location
    USA
    Posts
    147
    Thanks
    5
    Thanked 3 Times in 2 Posts

    flashcard script not working

    Here is the php

    PHP Code:
    <?php
    $flashcards 
    file_get_contents('flashcards.txt');
    $flashcards explode(',',$flashcards);

    $flashcards_number count($flashcards);
    $flashcards_number $flashcards_number-1;
    $random_note rand(0,$flashcards_number);

    $flashcard_picked rand(0,$flashcards_number);
    $flashcard_picked $flashcards[$flashcards_number];

    $spanish_word explode('|',$flashcard_picked);
    $spanish_word $spanish_word[0];

    $english_answer $spanish_word[1];

    echo 
    $spanish_word;
    echo 
    '<center>';
    echo 
    '<br /><a href=javascript:alert("' $english_answer '");>English Answer</a> | <a href="flashcard.php?card=' $random_note '">Random Flash Card</a>';
    echo 
    '</center>';
    ?>
    The text it is taking from is located at *example removed*

    The script itself is installed on *example removed*

    It won't switch words, it won't display the answer, and I'm kind of trying to prepare for an exam with this script. Could anybody help me get this working? Maybe I have my text file written front, maybe it's an error with the code.
    Last edited by doctordew; 01-20-2010 at 08:49 PM.
    Quote Originally Posted by rmedek View Post
    Doctordew, as soon as they come out with the opposite of an infraction, I am going to give you a million of them. You are my new favorite person on the forum.

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    what I changed is commented:
    PHP Code:
    <?php
    $flashcards 
    file_get_contents('flashcards.txt');
    $flashcards explode(',',$flashcards);

    $flashcards_number count($flashcards);
    $flashcards_number $flashcards_number-1;
    $random_note rand(0,$flashcards_number);

    $flashcard_picked rand(0,$flashcards_number);
    $flashcard_picked $flashcards[$flashcards_number];

    $spanish_word explode('|',$flashcard_picked);
    $spanish $spanish_word[0]; // changed this

    $english_answer $spanish_word[1];

    echo 
    $spanish// ... and this
    echo '<center>';
    echo 
    '<br /><a href=javascript:alert("' $english_answer '");>English Answer</a> | <a href="flashcard.php?card=' $random_note '">Random Flash Card</a>';
    echo 
    '</center>';
    ?>
    good luck with your exam,

    Edit: forget to explain.
    PHP Code:
    $spanish_word explode('|',$flashcard_picked);
    // next line will overwrite the array and $english_answer will be only first char
    $spanish_word $spanish_word[0];

    $english_answer $spanish_word[1]; 

    best regards
    Last edited by oesxyl; 01-20-2010 at 08:14 PM.

  • Users who have thanked oesxyl for this post:

    doctordew (01-20-2010)

  • #3
    Regular Coder
    Join Date
    Jul 2007
    Location
    USA
    Posts
    147
    Thanks
    5
    Thanked 3 Times in 2 Posts
    Two errors remained.

    PHP Code:
    $flashcard_picked $flashcards[$flashcard_picked]; 
    and
    PHP Code:
    $flashcard_picked rand(0,$flashcards_number); 
    $flashcard_picked $flashcards[$flashcards_number]; 
    It's up and running though, thanks!
    Quote Originally Posted by rmedek View Post
    Doctordew, as soon as they come out with the opposite of an infraction, I am going to give you a million of them. You are my new favorite person on the forum.


  •  

    Posting Permissions

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