954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Parse Error Problem


<?php
error_reporting(E_ALL & ~E_NOTICE);
function DisplayError($fieldName, $errorMsg) {
echo "Error for \"$fieldName\": $errorMsg
\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.
\n";
else {
$wordnum = 0;
foreach ($words as $Word)
echo "Word ", ++$wordnum.": $Word
\n";
}
?>

zlloyd1
Light Poster
41 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
 

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

Will Gresham
Master Poster
755 posts since May 2008
Reputation Points: 96
Solved Threads: 125
 

Replace the below line with your line 20

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


This should perfectly works...

Dragonbaki
Junior Poster
130 posts since Oct 2010
Reputation Points: 15
Solved Threads: 21
 
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

zlloyd1
Light Poster
41 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
 

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

zlloyd1
Light Poster
41 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
 

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

Dragonbaki
Junior Poster
130 posts since Oct 2010
Reputation Points: 15
Solved Threads: 21
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: