Parse error help

C++, C#, Java, PHP, ect...
Rob
Posts: 26
Joined: Thu Aug 06, 2009 10:40 pm

Parse error help

Post by Rob »

Well, I've highlighted the line the parse error is on, but I dont see the problem with it
if ($submit)
{
if ($password==$repeatpassword)
{
if (strlen($username)>21)
{
echo "Your Username is too Long.";
}
else
{
if (strlen($fullname)>25)
{
echo "Your Full Name is too long.";
}
else
{
if (strlen($password)>21)||strlen($repeatpassword)<6)
{
echo "You're password must be between 6 and 21 characters";
}
else
{
//register

}
}
else
{
echo "Your passwords do not match.";
}
}
User avatar
Sakar
Posts: 520
Joined: Thu Apr 23, 2009 2:59 am

Re: Parse error help

Post by Sakar »

I'm not exactly sure on this, but I believe you're missing a parenthesis before the second strlen (or you accidentally added one to the end of the first). Also I think you only need one | not two, but I'm not sure.
Rob
Posts: 26
Joined: Thu Aug 06, 2009 10:40 pm

Re: Parse error help

Post by Rob »

No, there's still an error with only one |
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: Parse error help

Post by Torniquet »

simple way to stop people making the length to long.

set the max length of an input box to the max you want to set.

then you can remove all the unneccesary checks in there.

then all you have to check lengthwise is the length of the password to make sure its over 6 characters.

also make sure it is that which is causing the problem by commenting it out. I often get it say 'parse error on line x' when infact it can be several lines above or below it. or is that just me not being able to read it properly lol.
New Site Coming Soon! Stay tuned :D
Rob
Posts: 26
Joined: Thu Aug 06, 2009 10:40 pm

Re: Parse error help

Post by Rob »

Ok, done all that, now I get a parse error on line 163

Code: Select all

<?php
include_once 'connect.php';
//strip tags and detect
$submit = strip_tags($_POST['submit']);
$fullname = strip_tags($_POST['fullname']);
$email = strip_tags($_POST['email']);
$username = strtolower(strip_tags($_POST['username']));
$password = strip_tags($_POST['password']);
$repeatpassword = strip_tags($_POST['repeatpassword']);
$date = date("Y-m-d");
$namecheck = mysql_query("SELECT username from players WHERE name='$username'");
$count = mysql_num_rows($namecheck);
$random = rand(11111111,99999999);


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome to Trident Online!</title>
<style="style.css"></style>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="800" border="0" cellspacing="0" cellpadding="0" align="center" name="main" id="main">
  <tr>
    <th height="200" colspan="3" scope="col" id="banner"><img src="images/banner.gif" width="800" height="200" alt="Trident Online" /></th>
  </tr>
  <tr>
    <td height="19" colspan="3" id="navbar"> <a href="index.php">Home</a><font color="#385E7F">__)_</font><a href="register.php">Register</a><font color="#385E7F">_____</font><a href="rules.php">Rules</a><font color="#385E7F">_____</font><a href="pm.php">About TO</a><font color="#385E7F">__)____</font><a href="contactus.php">Contact Us</a><font color="#385E7F">__)____</font><a href="forum/index.php">Forum</a></td>
  </tr>
  <tr>
    <td width="4" height="138" align="center" valign="top" id="mainnav"> </td>
    <td width="627" rowspan="2" align="center" valign="top"><h2> Registration   </h2>
    <p>Thank you for registering to Trident Online! Please complete the form below, all fields are required and once you're done you will recieve a confirmation email from Trident Online to confirm your registration. Remember to read the Terms and Conditions and Privacy Policy before registering so you know what you're signing up to.</p>
    <p><form action="register.php" method="POST">
    <table>
    <tr>
    <td>
    Your Name:<br />
    </td>
    <td>
    <input type="text" name="fullname" value="<?php echo $fullname; ?>">
    </td>
    </tr>
     <tr>
    <td>
    Username:<br />
    </td>
    <td>
    <input type="text" name="username" value="<?php echo $username; ?>">
    </td>
    </tr>
    <tr>
    <td>
    Password:<br />
    </td>
    <td>
    <input type="password" name="password"  maxlength="25">
    </td>
    </tr>
    <tr>
    <td>
    Repeat Password:<br />
    </td>
    <td>
    <input type="password" name="repeatpassword" maxlength="25">
    </td>
    </tr>
    <tr>
    <td>
    Email:<br />
    </td>
    <td>
    <input type="text" name="email" />
    </td>
    </tr>
    <tr>
    <td colspan="2">
      <p align="center"><input type="submit" name="submit" value="Register" /></p>
    </td>
    </tr>
    </table>
    </form>
    </p><p align="left">
<?php

if ($submit)
{
	if ($count!=0)
	{
		echo "Username already exists";
	}
	else
	{
	if ($password==$repeatpassword)
	{
		if (strlen($username)>21)
				   {
						echo "Your Username is too Long.";
				   }
				   else
				   {
					   if (strlen($fullname)>25)
					   {
							echo "Your Full Name is too long.";
					   }
					   else
					   {
						   if (strlen($password)<6)
						   {
								echo "You're password must be more than 6 characters";
						   }
						   else
						   {
							   //register
								md5($password);
								$queryreg = mysql_query("INSERT into players values('', '$username', '$password', '$email' '$fullname', '$date', '$random', '0'");
								//send email
								$lastid = mysql_insert_id();
								$to = $email;
								$subject = "Activate your Trident Online account.";
								$headers = "From: activate@tridentonline.com";
								$server = "webmail.tridentonline.com";
								$body = "Hello $fullname, \n\n
								
								You need to activate your Trident Online account, you can do this by clicking the link below\n
								http://www.tridentonline.com/activate.php?id=$lastid&code=$random\n\n
								
								Thanks for registering,
								Trident Online Staff.";
								mail($to, $subject, $body, $headers);
								die("You have been succesfully registered! Login by using the sidebar!");
						   }
					   }
				   }
	}
	else
	{
		echo "Your passwords do not match.";
	}
}
	
?>
    </p></td>
    <td width="169" valign="top"><p align="center"><strong>Login</strong></p>
      <p align="center"><iframe src="login.php" width="100%" frameborder="0" height="100" scrolling="no"></iframe><br />
    </p></td>
  </tr>
  <tr>
    <td height="258" valign="top"></td>
    <td valign="top"> </td>
  </tr>
</table>
<br />
<div id="numplayers" align="center">There are currently 	<?php $query = mysql_query("SELECT * from players");
	$numrows = mysql_num_rows($query);
	echo($numrows);
	?> users registered</div>
</body>
</html>
User avatar
Noctrine
Posts: 928
Joined: Thu Apr 23, 2009 9:57 pm

Re: Parse error help

Post by Noctrine »

How long do you look for the problem in your code before asking for help?
Jesse Dorsey
ProjectANI - Lead Developer Person
http://about.me/jessedorsey
Rob
Posts: 26
Joined: Thu Aug 06, 2009 10:40 pm

Re: Parse error help

Post by Rob »

I look until the points where I dont understand the problem
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: Parse error help

Post by Torniquet »

I dont know whether its this or not... but you havnt assigned your hashed PW a variable as far as i can see.
New Site Coming Soon! Stay tuned :D
User avatar
Noctrine
Posts: 928
Joined: Thu Apr 23, 2009 9:57 pm

Re: Parse error help

Post by Noctrine »

So when you don't immediately get something you just stop and ask for help?
Jesse Dorsey
ProjectANI - Lead Developer Person
http://about.me/jessedorsey
Rob
Posts: 26
Joined: Thu Aug 06, 2009 10:40 pm

Re: Parse error help

Post by Rob »

No, I look at it for as long as i can without going insane over not knowing what the problem is
Post Reply

Return to “Coding”