
|
View Full Version : Random PHP Parse Error
Falco1199 09-25-2002, 11:49 PM Here's my script; it gets registration info, links to itself w/ a GET variable, which triggers the page to not get info but to check if the given info is valid and then either say it's valid or re-show the form:
<html>
<head>
<title>CGP-RPG Registration</title>
<?php include("/rpg/include/RPGhead.inc"); ?>
</head>
<body>
<?php include("/rpg/include/RPGupper.inc"); ?>
<? php
$formCode =
"<form method=/"POST/" action=/"register.php?reg=true/">/n/r
RPG Name: <input type=/"text/" size=/"12/" name=/"memName/" value=/"$memName/">(Up to 12 characters long; Numbers, letters, and underscores(_) only)<br />/n/r
Password: <input type=/"password/" size=/"12/" name=/"passWord/">(4-12 characters long; Numbers and letters only)<br />/n/r
Repeat Password: <input type=/"password/" size=/"12/" name=/"passWordRep/"><br />/n/r
Email Address: <input type=/"text/" size=/"30/" name=/"userEmail/" value=/"$userEmail/">(Must be a valid email address, such as: Joe@schmoe.com)<br />/n/r
<input type=/"submit/" value=/"Submit!/"><br />/n/r
</form>/n/r"
if (!isSet($reg)) {
?>
<blockquote>To register for CGRPG, simply fill out the form below and click the "Submit" button. Please note that your email address will not be publicized,
and that only Falco1199 will even be able to see it. It is only used for sending emails about new RPG quests or features, and will be used VERY infrequently.</blockquote><br /><br />
<?php print($formCode); ?>
<?php
} else {
if (ereg('^[[:upper:][:lower:][:alnum:]_]\+$',$memName) && strlen($memName) <= 12 && strlen($memName) < 0)
{
if (ereg('^[[:upper:][:lower:][:alnum:]_]\+$',$passWord) && strlen($password) <= 12 && strlen($password) >= 4)
{
if ($passWord === $passWordRep)
{
if (ereg('^.\+@.\+\..\+$',$userEmail))
{
/* Here's what happens with a good form (much more will be here later) */ print("Form is good!");
}
else
{
?>
<span style="COLOR: RED"><b>ERROR!</b> Your email address isn't valid.</span>
print($formCode);
<?php
}
else
{
?>
<span style="COLOR: RED"><b>ERROR!</b> Your passwords don't match.</span>
print($formCode);
<?php
}
else
{
?>
<span style="COLOR: RED"><b>ERROR!</b> Your password isn't valid.</span>
print($formCode);
<?php
}
else
{
?>
<span style="COLOR: RED"><b>ERROR!</b> Your team name isn't valid.</span>
print($formCode);
<?php
}
?>
<?php include("/rpg/include/RPGlower.inc"); ?>
</body>
</html>
And I get this error:
Parse error: parse error in (server path to site here)/rpg/register.php on line 10
Does anyone see my problem? It seems to be just a variable assignment...
The Prohacker 09-26-2002, 12:01 AM $formCode = "<form method=\"POST\" action=\"register.php?reg=true\">\n\r
RPG Name: <input type=\"text\" size=\"12\" name=\"memName\" value=\"$memName\">(Up to 12 characters long; Numbers, letters, and underscores(_) only)<br \>\n\r
Password: <input type=\"password\" size=\"12\" name=\"passWord\">(4-12 characters long; Numbers and letters only)<br \>\n\r
Repeat Password: <input type=\"password\" size=\"12\" name=\"passWordRep\"><br \>\n\r
Email Address: <input type=\"text\" size=\"30\" name=\"userEmail\" value=\"$userEmail\">(Must be a valid email address, such as: Joe@schmoe.com)<br \>\n\r
<input type=\"submit\" value=\"Submit!\"><br \>\n\r
<\form>\n\r";
You use \ not / when you need to use " "'s :D
The Prohacker 09-26-2002, 12:03 AM You also forgot the ; at the end of the varible definiton....
$var = "bleh";
tapster 09-26-2002, 12:06 AM yeah. wrong escape character :)
also, you don't want a space in your php opening tag
<? php
should be
<?php
also missing the ; at the end of that long line...
if statement nesting looks a bit off too, but I've got to get back to work :(
happy coding
Falco1199 09-26-2002, 05:59 PM Alright, thanks a lot!
Now I get a parse error on line 43, which is the ELSE in the following section:
<span style="COLOR: RED"><b>ERROR!</b> Your email address isn't valid.</span>
print($formCode); /* line 40 */
<?php
}
else
{
Does anyone see this problem??
Originally posted by Falco1199
Now I get a parse error on line 43, which is the ELSE in the following section:
Does anyone see this problem??
You're using 'print' outside the PHP
Should be
<span style="COLOR: RED"><b>ERROR!</b> Your email address isn't valid.</span>
<?php
print($formCode); /* line 40 */
}
else
{
tapster 09-26-2002, 06:11 PM also, as I mentioned before, your nesting is off...
you have this going on...
if()
{
}
else
{
}
else
{
}
can't have 2 elses :)
MGCJerry 09-26-2002, 06:55 PM Instead of the 2 elses which you really can't do (which is already mentioned) you can do:
if () {
} elseif {
} else {
}
I'm pretty sure this will work as intended.
Barak 09-26-2002, 07:11 PM ... as long as you put another condition to go with the elseif, eg.
if ($x == $y) {
}
elseif ($x == $z) {
}
else {
}
tapster 09-26-2002, 07:13 PM I think in fact, he's missing a closing } on one of the outer if statements
tidy up the code, and it will be clear :)
Falco1199 09-28-2002, 08:32 PM Alright, I added some close brackets, and thought I had fixed it, but I still get a parse error on line 50.
<html>
<head>
<title>CGP-RPG Registration</title>
<?php include("/home/virtual/cgplatinum.com/var/www/html/rpg/include/RPGhead.inc"); ?>
</head>
<body>
<?php include("/home/virtual/cgplatinum.com/var/www/html/rpg/include/RPGupper.inc"); ?>
<?php
/* line 10 */ $formCode =
"<form method=\"POST\" action=\"register.php?reg=true\">\n\r
RPG Name: <input type=\"text\" size=\"12\" name=\"memName\" value=\"$memName\">(Up to 12 characters long; Numbers, letters, and underscores(_) only)<br />\n\r
Password: <input type=\"password\" size=\"12\" name=\"passWord\">(4-12 characters long; Numbers and letters only)<br />\n\r
Repeat Password: <input type=\"password\" size=\"12\" name=\"passWordRep\"><br />\n\r
Email Address: <input type=\"text\" size=\"30\" name=\"userEmail\" value=\"$userEmail\">(Must be a valid email address, such as: Joe@schmoe.com)<br />\n\r
<input type=\"submit\" value=\"Submit!\"><br />\n\r
</form>\n\r";
if (!isSet($reg)) {
/* line 20 */ ?>
<blockquote>To register for CGRPG, simply fill out the form below and click the "Submit" button. Please note that your email
address will not be publicized, and that only Falco1199 will even be able to see it.
It is only used for sending emails about new RPG quests or features, and will be used VERY infrequently.</blockquote><br /><br />
<?php print($formCode); ?>
<?php
} else {
if (ereg('^[[:upper:][:lower:][:alnum:]_]\+$',$memName) && strlen($memName) <= 12 && strlen($memName) < 0)
{
if (ereg('^[[:upper:][:lower:][:alnum:]_]\+$',$passWord) && strlen($password) <= 12 && strlen($password) >= 4)
{
if ($passWord === $passWordRep) /* line 30 */
{
if (ereg('^.\+@.\+\..\+$',$userEmail))
{
/* Here's what will happen with a good form */ print("Form is good!");
}
else
{
?>
<span style="COLOR: RED"><b>ERROR!</b> Your email address isn't valid.</span>
<?php /* line 40 */
print($formCode);
}
}
else
{
?>
<span style="COLOR: RED"><b>ERROR!</b> Your passwords don't match.</span>
<?php
print($formCode)
}
}
else /* line 50 */
{
?>
<span style="COLOR: RED"><b>ERROR!</b> Your password isn't valid.</span>
<?php
print($formCode);
}
}
else
{
?>
<span style="COLOR: RED"><b>ERROR!</b> Your team name isn't valid.</span>
<?php
print($formCode);
}
?>
<?php include("/home/virtual/cgplatinum.com/var/www/html/rpg/include/RPGlower.inc"); ?>
</body>
</html>
What now?:(
you're missing a semi-colon on the print($formCode) before where you have marked as line 50
Here.. try this :)
<html>
<head>
<title>CGP-RPG Registration</title>
<?php include("/home/virtual/cgplatinum.com/var/www/html/rpg/include/RPGhead.inc"); ?>
</head>
<body>
<?php
include("/home/virtual/cgplatinum.com/var/www/html/rpg/include/RPGupper.inc");
$formCode =
"<form method=\"POST\" action=\"register.php?reg=true\">\n\r
RPG Name:*<input type=\"text\" size=\"12\" name=\"memName\" value=\"$memName\">(Up to 12 characters long; Numbers, letters, and underscores(_) only)<br />\n\r
Password:*<input type=\"password\" size=\"12\" name=\"passWord\">(4-12 characters long; Numbers and letters only)<br />\n\r
Repeat Password:*<input type=\"password\" size=\"12\" name=\"passWordRep\"><br />\n\r
Email Address:*<input type=\"text\" size=\"30\" name=\"userEmail\" value=\"$userEmail\">(Must be a valid email address, such as: Joe@schmoe.com)<br />\n\r
<input type=\"submit\" value=\"Submit!\"><br />\n\r
</form>\n\r";
if (!isSet($reg)) {
?>
<blockquote>To register for CGRPG, simply fill out the form below and click the "Submit" button. Please note that your email
address will not be publicized, and that only Falco1199 will even be able to see it.
It is only used for sending emails about new RPG quests or features, and will be used VERY infrequently.</blockquote><br /><br />
<?php print($formCode);
} else {
if (ereg('^[[:upper:][:lower:][:alnum:]_]\+$',$memName) && (strlen($memName) <= 12) && (strlen($memName) < 0))
{
if (ereg('^[[:upper:][:lower:][:alnum:]_]\+$',$passWord) && (strlen($password) <= 12) && (strlen($password) >= 4))
{
if ($passWord == $passWordRep)
{
if (ereg('^.\+@.\+\..\+$',$userEmail))
{
print("Form is good!"); // Here's what will happen with a good form
}
else
{ ?>
<span style="COLOR: RED"><b>ERROR!</b> Your email address isn't valid.</span>
<?php
print($formCode);
}
}
else
{
?>
<span style="COLOR: RED"><b>ERROR!</b> Your passwords don't match.</span>
<?php
print($formCode);
}
}
else
{
?>
<span style="COLOR: RED"><b>ERROR!</b> Your password isn't valid.</span>
<?php
print($formCode);
}
}
else
{
?>
<span style="COLOR: RED"><b>ERROR!</b> Your team name isn't valid.</span>
<?php
print($formCode);
}
}
include("/home/virtual/cgplatinum.com/var/www/html/rpg/include/RPGlower.inc");
?>
</body>
</html>
You might also want to check your capitalization, I notice you used $passWord *and* $password...
Falco1199 09-28-2002, 09:19 PM Where does it say "password"? They all look like "passWord" to me.
if (ereg('^[[:upper:][:lower:][:alnum:]_]\+$',$passWord) && (strlen($password) <= 12) && (strlen($password) >= 4))
I wasn't sure if it was intentional, so I left it in my code sample
did the code i posted work out for you?
Falco1199 10-01-2002, 12:33 AM The problems I had are solved, but a new one has arisen. My regexps don't seem to be functioning properly; I typed in the username "this", password "this", passwordrep "this" and email "this@that.com" and I got the I programmed the script to write when the username was incorrect. Does anyone see the problem?
BTW, I edited the passWord variables so that they're all passWord. ;)
Falco1199 10-02-2002, 12:13 PM No one sees a problem with the regexps? Then why am I getting this error message? BTW, you can still see the page at
www.cgplatinum.com/rpg/register.php
? :)
Falco1199 10-16-2002, 04:44 PM OK, I hate to bump this AGAIN, but I'm changing my level of desperation.
Is the reason no one's responded that they're correct? Could someone look at my regexps, and tell if they're wrong OR not, even if they don't have a possible solution?
??? :)
MarlboroMan 10-19-2002, 07:55 AM (ereg('^[[:upper:][:lower:][:alnum:]_]\+$',$memName) && (strlen($memName) <= 12) && (strlen($memName) < 0))
Read that again....
Pretty impossible for a strlen to be LESS than 0. You need to change that last check.
Also, I think it's better coding practice (IMHO) to test for negatives, so you tell immediately from looking at the code what error message is outputted for each failed test eg.
if (!ereg('^[[:upper:][:lower:][:alnum:]_]\+$',$memName) || (strlen($memName) > 12) || (strlen($memName) < 0))
{
// error stuff here
}
else
{
// continue on with your merry life
}
Falco1199 10-20-2002, 03:56 PM OH thanks!
|