Jump to content

Robby McDonald

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Everything posted by Robby McDonald

  1. Alright it was just a text editor problem. With that solved, could you recommend a text editor for me? Also where is the solved button?
  2. I have one small question about comments. say you have a code like this <?php $lol = 1; $rofl = 2; $lmao = 3; // Above are my variable's echo 'this does not get executed because the apostrophy in the comment acts as the start'; ?> Now if I wrote this code the apostrophe in variable acts as a quote and does not end until it meets another to end it. Why does this do that? I thought that when you start a comment that whole line gets ignored. Could this possible be happening because of my text editor( I use textpad )? If so could you recommend a good text editor, thanks.
  3. Ok I decided to brush up on some functions and this one was giving me a hard time. Basically the if condition is printing the statement even though its not what the expression was asking for. I'm positive I am just missing something small, but I can't figure it out. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xm1ns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Counting Words...</title> </head> <body> <?php function count_words() { $totalwords = str_word_count($_POST['total']); $amountneeded = $_POST['amount']; $wordsneeded = $amountneeded - $totalwords; $extrawords = $totalwords - $amountneeded; if (isset($_POST['submitted'])) { if(str_word_count($_POST['totalwords']) <= $_POST['amountneeded']) { print "\nYou need $wordsneeded more words"; } else { print "\nYou wrote an extra $extrawords words"; } if(str_word_count($_POST['totalwords']) == $_POST['amountneeded']) { print "You hit the jackpot and got just as much words as you needed"; } } } ?> <form action="wordcount.php" method="post"> <p>Words Needed: <input type="text" name="amount" value="" /></p> <p>Copy and Paste your words:</p> <textarea name="total" rows="5" cols="30"></textarea> <input type="submit" name="submit" value="Count My Words" /> <input type="hidden" name="submitted" value="true" /> </form> <?php count_words(); ?> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.