I have recently been getting a parse error that reads :

Parse error: parse error in C:\wamp\www\Jumble.php on line 20

Anytime I run an HTML program on my wamp server and it is regarding a php file called Jumble.php which is supposed to arrange the data entered into the HTML file. The HTML file seems to work spot on so i won't bother you with it's code but I will post the code for Jumble.php in the hopes that someone else can see what I am unable to find:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<title>Word Jumble</title>
<body>
<?php 
   error_reporting(E_ALL & ~E_NOTICE);
   function DisplayError($fieldName, $errorMsg) {
    echo "Error for \"$fieldName\": $errorMsg<br \>\n";
    ++$errorCount;  }
    function wordCheck($data, $fieldName) {

        global $errorCount;
         if (empty($data)) {
            displayError($fieldName, "You must enter a word here between 4 and 7 characters");
            $retval = "";}
          else {
            $retval = trim($data);
                    $retval = striplashes($retval);
****line 20****     if (strlen(($retval)<4)) || (strlen($retval)>7)) { 
            displayError($fieldName, "Must be between 4 ans 7 characters in length");}  
            if (preg_match("/^[a-z]+$/i", $retval)==0){
                displayError($fieldName, "Words must be letters only");
            }
            }
            $retval = stroupper($retval);
            $retval = str_shuffle($retval);
            reutrn($retval);
            }
            $words[] = wordCheck($_POST["word 1"], "word 1");
            $words[] = wordCheck($_POST["word 2"], "word 2");
            $words[] = wordCheck($_POST["word 3"], "word 3");
            $words[] = wordCheck($_POST["word 4"], "word 4");
            if ($errorCount>0)
               echo "Please re-enter data.<br />\n";
            else {
                $wordnum = 0;
                foreach ($words as $Word)
                   echo "Word ", ++$wordnum.": $Word<br />\n";
                            }   
?>
</body> 
</html>

Line 20 is where the error is saying I am having issues but I cannot for the life of me see what would be causing it!! PLEASE HELP ME!!!!:confused:

Recommended Answers

All 5 Replies

Check the braces, your || is not within them.

Replace the below line with your line 20

if ((strlen($retval)<4) || (strlen($retval)>7))

This should perfectly works...

Check the braces, your || is not within them.

Thank you a million for taking the time to answer me and yes that was the issue but now I am trying to figure out why my if statements are not working correctly. But at least it is running now, just giving incorrect results :P
But again thanks for that tip it did help!!
Thanks,
Zack

Replace the below line with your line 20

if ((strlen($retval)<4) || (strlen($retval)>7))

This should perfectly works...

Thanks a bunch for the help!! It worked too I stopped getting error messages but now I am getting incorrect results :( but that is just my thinking and not the server errors so I can work that out easily enough. I just am repulsed by error messages and did not notice the brackets missing in the line and for that I am grateful for your reply!!
Thanks,
Zack

For any kind of help, ideas or suggestions, feel free to communicate with us.. We will always with you...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.