Jump to content

Can't find parse error


cberube09

Recommended Posts

Hi, this is a simple question but I've been struggling for days to find this parse error and I haven't been able to find it!  I get a parse error on line 127.  This is the line that has all of the !isset statements.

 

<div id="mainnew">
<a href="index.php?content=neweditorials"><img border="0" src="images/neweditorials.png" />
</a>
</div>
<div id="maintoprated">
<a href="index.php?content=topratededitorials"><img border="0" src="images/topratededitorials.png" />
</a>
</div>
<div id="mainmostpopular">
<a href="index.php?content=mostpopulareditorials"><img border="0" src="images/mostpopulareditorials.png" /></a>
</div>

<?php

function newForm()
{
$username=$_POST['username'];
$password=$_POST['password'];
$password2=$_POST['password2'];
$email=$_POST['email'];
$gender=$_POST['gender'];
?>

<div align="left" class="maincontent">
        <div class='boldunderl'>Create Your Account</div><br />
        <form method="post" id="createaccountform" action="index.php?content=addaccount">
		<div>
            	<label for="username">Username<br /></label>
			<input id="username" name="username" type="text" value="<?php echo $username; ?>" />
		</div>
                <br />
            <div>
			<label for="password">Password<br /></label>
			<input id="password" name="password" type="text" value="<?php echo $password; ?>" />
		</div>
            <br />
            <div>
			<label for="password2">Confirm Password<br /></label>
			<input id="password2" name="password2" type="text" value="<?php echo $password2; ?>" />
		</div>
            <br />
            <div>
			<label for="email">Email Address<br /></label>
			<input id="email" name="email" type="text" value="<?php echo $email; ?>" />
		</div>
            <br />
		<div>
            	<label for="gender">Gender<br /></label>
                <?php
			if($gender=='Male')
			{ ?>
			<input id="gender" name="gender" type="radio" value="Male" checked />Male
                <input id="gender" name="gender" type="radio" value="Female" />Female
                <?php
			}else{ ?>
                <input id="gender" name="gender" type="radio" value="Male" />Male
                <input id="gender" name="gender" type="radio" value="Female" checked />Female
                <?php
			} ?>
		</div>
            <br />
		<div align="center">
			<input id="send" name="send" type="image" value="Submit" src="images/submit.png" />
                <input type="hidden" name="addaccount" value="addaccount" />
		</div>
            <br />
	</form>
        </div>
<?php
}
?>


<?php

$username=$_POST['username'];
$password1=$_POST['password'];
$password2=$_POST['password2'];
$email=$_POST['email'];
$gender=$_POST['gender'];

if((strlen($username)) < 3)
{
  $error1=array('username1'=>'<b>Error:</b> Your username must be at least 3 characters long!<br>');
}

if(preg_match("/([^0-9a-zA-Z ])/" , $username))
{
 $error2=array('username2'=>'<b>Error:</b> Your username must contain only letters or numbers!<br>');
}

if((empty($password1)))
{
  $error3=array('password1'=>'<b>Error:</b> You haven\'t chosen a password!<br>');
}

if((empty($password2)))
{
  $error4=array('password2'=>'<b>Error:</b> You haven\'t confirmed your password!<br>');
}

if($password1!=$password2)
{
  $error5=array('password3'=>'<b>Error:</b> Your passwords do not match!<br>');
}

if((empty($email)))
{
  $error6=array('email1'=>'<b>Error:</b> You haven\'t filled in your email address!<br>');
}

if(preg_match("/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/" , $email))
{
 $error7=array('email2'=>'<b>Error:</b> Your email format is incorrect!<br>');
}

if((empty($gender)))
{
  $error8=array('gender1'=>'<b>Error:</b> You must select a gender!<br>');
}

if((strlen($username)) > 15)
{
  $error9=array('username3'=>'<b>Error:</b> Your username must not be more than 15 characters long!<br>');
}

if (!isset($error1) && !isset($error2) && !isset($error3) && !isset($error4) && !isset($error5) && !isset($error6) && !isset($error7) !isset($error8) !isset($error9)) {
  include("config.php");
  include("dbconnect.php");
  $query="INSERT INTO users (username, password, email, gender, date) VALUES ('$username', '$password1', '$email', '$gender', NOW() )";
  $result=mysql_query($query) or die('Sorry, could not query the database'." Error: ".mysql_error());
  if ($result)
  {
  $categoryout = str_replace (" ", "_", $categoryselect);
  $titleout = str_replace (" ", "_", $editorialtitle);
    header("Location:index.php?content=main&id=$categoryout&title=$titleout");
  }else
  {
    echo "<div class=boldcenter>Sorry, there was a problem posting your editorial</div>";
  }
}
else {
echo'<div class=formerror align=left>';
  if(isset($error1['username1'])){echo $error1['username1'];}
  if(isset($error2['username2'])){echo $error2['username2'];}
  if(isset($error9['username3'])){echo $error9['username3'];}
  if(isset($error3['password1'])){echo $error3['password1'];}
  if(isset($error4['password2'])){echo $error4['password2'];}
  if(isset($error5['password3'])){echo $error5['password3'];}
  if(isset($error6['email1'])){echo $error6['email1'];}
  if(isset($error7['email2'])){echo $error7['email2'];}
  if(isset($error8['gender1'])){echo $error8['gender1'];}
  echo'</div>' , '<br>';
  newForm();
}
?>
</div>

 

The code is not finished yet, I have not finished changing some of the words, the header location, or the security yet.  Right now I'm just focused on finding the parse error.  Can anybody help?  Thanks!

Link to comment
https://forums.phpfreaks.com/topic/150596-cant-find-parse-error/
Share on other sites

You are missing a bunch of && 's....

<?php
if (!isset($error1) && !isset($error2) && !isset($error3) && !isset($error4) && !isset($error5) && !isset($error6) && !isset($error7) !isset($error8) !isset($error9)) {
?>

Should be:

<?php
if (!isset($error1) && !isset($error2) && !isset($error3) && !isset($error4) && !isset($error5) && !isset($error6) && !isset($error7) && !isset($error8) && !isset($error9)) {
?>

Last Edit:

Today at 01:29:15 PM

I beat both of you but by seconds... lol... very close.

you have no logical operators in between 7,8,9

 

i assume you want the if() to fail if 7 8 and 9 are not set, so try

 

try

if (!isset($error1) && !isset($error2) && !isset($error3) && !isset($error4) && !isset($error5) && !isset($error6) && (!isset($error7) && !isset($error8) && !isset($error9))) {

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.