Hello.
Although I have seen someone else having a similar problem here, I got stuck with an error.
This is the code and it shows a red parenthesis.

<!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">
   <head>
   <title>JumbleMaker</title>
   </head>
   <body>
   <?php
   function DisplayError($fieldName, $errorMsg) {
   global $errorCount;
   echo "Error for\"$fieldName\":$errorMsg<br/>\n";
   ++$errorCount;
   }
   functionvalidateWord($data,$fieldName){ <--- THIS IS THE RED PARENTHESIS
    global $errorCount;
       if (empty($data)){
        displayError($fieldName,"Welcome");
        $retval="TRUE";
        }else{
            $retval=trim($data);
            $retval=stripslashes($retval);
            if((strlen($retval)<4)||(strlen($retval)>7)){
    displayError($fieldName,"FALSE");
    }
    if(preg_match("/^[a-z]+$/i",$retval)==0){
    displayError($fieldName,"Words must be letters only");
    }
    $retval=strtoupper($retval);
    $retval=str_shuffle($retval);
    return($retval);
    }
    $word[]=validateword($_POST['word1'], "word1");
    $word[]=validateword($_POST['word2'], "word2");
    $word[]=validateword($_POST['word3'], "word3");
    $word[]=validateword($_POST['word4'], "word4");
    if($errorCount>0)
    echo "Please use the \"back\" button to re-enter the data.<br/>\n";
    else {

        $wordnum=0;
        foreach ($words as $word)
        echo "Word ".++$wordnum.":$word<br />\n";
    }
    ?>
    </body>
    </html>

Hi,

Your problem maybe because there is no space between function and the function name in the following line.

functionvalidateWord(.. //this must be
function validateWord(...

Also, do use CODE tags to wrap your code. :)

Hope this solved the issue.

When I run the code I got this message:
( ! ) Notice: Undefined variable: fieldName in H:\Program Files (x86)\wamp\www\Homework\PinedaAssignment3\process_JumbleMaker.php on line 18
Call Stack
# Time Memory Function Location
1 0.0006 690776 {main}( ) ..\process_JumbleMaker.php:0
Error for"":This field is required

( ! ) Notice: Undefined index: word1 in H:\Program Files (x86)\wamp\www\Homework\PinedaAssignment3\process_JumbleMaker.php on line 33
Call Stack
# Time Memory Function Location
1 0.0006 690776 {main}( ) ..\process_JumbleMaker.php:0

( ! ) Notice: Undefined index: word2 in H:\Program Files (x86)\wamp\www\Homework\PinedaAssignment3\process_JumbleMaker.php on line 34
Call Stack
# Time Memory Function Location
1 0.0006 690776 {main}( ) ..\process_JumbleMaker.php:0

( ! ) Notice: Undefined index: word3 in H:\Program Files (x86)\wamp\www\Homework\PinedaAssignment3\process_JumbleMaker.php on line 35
Call Stack
# Time Memory Function Location
1 0.0006 690776 {main}( ) ..\process_JumbleMaker.php:0

( ! ) Notice: Undefined index: word4 in H:\Program Files (x86)\wamp\www\Homework\PinedaAssignment3\process_JumbleMaker.php on line 36
Call Stack
# Time Memory Function Location
1 0.0006 690776 {main}( ) ..\process_JumbleMaker.php:0
Please use the "back" button to re-enter the data.


I am doing something wrong because is not processing the form correctly. :0(

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.