Re: Comparing strings
| From: | phantom | Date: | Thu, 01 Nov 2001 10:38:52 +0000 |
| Subject: | Re: Comparing strings | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-73135@lists.php.net to get a copy of this message | ||
Must have been a missing semi-colon it works now. Thanks.
<%
echo $Action;
if ($Action == "Submit")
{ echo " Process form"; }
else
{ echo " Do Nothing"; }
%>
<html>
<form method="Post" action="self.php">
<input type="text" name="Var1" maxlength="20">
<input type="submit" name="Action" value="Submit">
</form>
</html>
Cc Zona wrote:
> In article <3BE1136F.5294A6B5@phantomcougar.com>,
> phantom@phantomcougar.com (Phantom) wrote:
>
> > In PHP I have tried
> >
> > if ($Action == "Submit") but I get a parse error in that statement.
> > What am I doing wrong? Thank you. I did an echo $Action to confirm
> > that it's value is Submit.
>
> If the variable is set as you've confirmed, then that should work. If PHP
> is reporting a parse error with that line number, note that the lines where
> PHP stopped parsing isn't necessarily the line where the bad code resides.
> Try checking back a few lines; you may have left off a semi-colon or
> somesuch. Another idea: check that the variable's length is the expected 5
> chars; maybe there's some trailing whitespace that's causing the comparison
> to fail (trim() is handy for avoiding this gotcha). If neither of those
> solve the problem, try re-posting with a larger code snippet.
>
> --
> CC