LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-02-2012, 05:02 PM   #1
nothing07
LQ Newbie
 
Registered: Jun 2012
Posts: 11

Rep: Reputation: Disabled
Parse error: syntax error, unexpected $end in /home/a7358914/public_html/index.php on


i don't know what i have don wrong in my script, but i am always getting this massage "Parse error: syntax error, unexpected $end in /home/a7358914/public_html/index.php on line 134" i diden't really understand it either, so i hope that someone can help me
 
Old 06-02-2012, 05:04 PM   #2
nothing07
LQ Newbie
 
Registered: Jun 2012
Posts: 11

Original Poster
Rep: Reputation: Disabled
Code:
>this is my script, i think i may have several fails, so i wish someone can help me with fixing them. sorry for my bad english
<html>
	// E-mail and password form thingy to login
	<form action='login.php' method='POST'>
		<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='email' name='email' value="">
		<input type='password' name='password'>
		<input type='submit' value='log in'><br><br><hr>
	</form>	

	// register box
    <?php
	echo "<h1>Sign up</h1>";
	
	$submit = $_POST['submit'];
	
	//form data
	$firstname = strip_tags($_POST['firstname']);
	$lastname = strip_tags($_POST['lastname']);
	$email =strtolower(strip_tags($_POST['email']));
	$password =md5 (strip_tags($_POST['password']));
	$repeatpassword =md5 (strip_tags($_POST['repeatpassword']));
	$date = date("Y-m-d")
;	
if ($submit)
{
	
	//open database
		$connect = mysql_connect("xxx","xxx","xxx");
mysql_select_db("xxx"); //select database

	$namecheck = mysql_query("SELECT email FROM users WHERE email='$email'");
	$count = mysql_num_rows($namecheck);
	
	if ($count!=0)
	{
	die("Email already in use!");	
	}
	
		
	//check for existance
	if ($firstname&&$lastname&&$email&&$password&&$repeatpassword)
	{
		if ($password==$repeatpassword)
		{
		//check char lenht of email, firstname and lastname
		if (strlen($email)>25||strlen($firstname)>25||strlen($lastname)>25)
		{
		echo "length of email or firstname or lastname is too long!";
		}
		else 
		{
		//check password length
		if (strlen($password)>25||strlen($password)<6)
		{
		echo "password must be between 6 and 25 charaters";
		}
		else
		{
		//register the user!
		
		// encript password
		$password = md5 ($password);
		$repeatpassword = md5 ($repeatpassword);
		
		

		$queryreg = mysql_query("
		
		INSERT INTO users VALEU ('','$firstname','$email','$password','$date')
		
		");
		
		die ("You have been registered!");
		
		}
		

	    echo "your password do not match!";
}

	}
	else
		echo "Please fill in <b>all</b> fields!";
	
}
?>
<p>
    
    <form action="register.php" method="POST">
    	<table>
        	<tr>
				<td>
                first name
                </td>
                <td>
                <input type="text" name:"firstname"> value="<?php echo $firstname; ?>">
				</td>
            </tr>
            <tr>
				<td>
                last name
                </td>
                <td>
                <input type="text" name:"lastname"> value="<?php echo $lastname; ?>">
				</td>
            </tr>
            <tr>
				<td>
                Email
                </td>
                <td>
                <input type="email" name:"email"> value="<?php echo $email; ?>">
				</td>
            </tr>
            <tr>
				<td>
                password
                </td>
                <td>
                <input type="password" name:"password"  
				</td>
            </tr>
            <tr>
				<td>
                Repeat password                
                </td>
                <td>
                <input type="password" name:"Repeatpassword"  
				</td>
            </tr>
		</table>
        <p>
        <input type="submit" name="submit" value="Register">
	</form>
</html>

Last edited by nothing07; 06-03-2012 at 12:04 PM.
 
Old 06-02-2012, 06:31 PM   #3
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
Please use CODE tags when you paste script code. Also use a good code editor with coloring syntax, to catch that errors.

The error is caused by not closed curly brace for "if". You also had other mistakes, like not closed "input" tags, semicolons instead of equality signs, and not closed "p" tag. Check this:
PHP Code:
<html><body>
// E-mail and password form thingy to login
<form action='login.php' method='POST'>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='email' name='email' value="">
<input type='password' name='password'>
<input type='submit' value='log in'><br><br><hr>
</form>

// register box
<?php
echo "<h1>Sign up</h1>";

$submit $_POST['submit'];

//form data
$firstname strip_tags($_POST['firstname']);
$lastname strip_tags($_POST['lastname']);
$email =strtolower(strip_tags($_POST['email']));
$password =md5 (strip_tags($_POST['password']));
$repeatpassword =md5 (strip_tags($_POST['repeatpassword']));
$date date("Y-m-d");
if (
$submit)
  {

  
//open database
  
$connect mysql_connect("xxx","xxx","");
  
mysql_select_db("xxx"); //select database

  
$namecheck mysql_query("SELECT email FROM users WHERE email='$email'");
  
$count mysql_num_rows($namecheck);

  if (
$count!=0)
    {
    die(
"Email already in use!");
    }


  
//check for existance
  
if ($firstname&&$lastname&&$email&&$password&&$repeatpassword)
    {
    if (
$password==$repeatpassword)
      {
      
//check char lenght of email, firstname and lastname
      
if (strlen($email)>25||strlen($firstname)>25||strlen($lastname)>25)
    {
    echo 
"length of email or firstname or lastname is too long!";
    }
      else
    {
    
//check password length
    
if (strlen($password)>25||strlen($password)<6)
      {
      echo 
"password must be between 6 and 25 charaters";
      }
    else
      {
      
//register the user!

      // encript password
      
$password md5 ($password);
      
$repeatpassword md5 ($repeatpassword);
      
$queryreg mysql_query("
        INSERT INTO users VALEU ('','
$firstname','$email','$password','$date')
        "
);
      die (
"You have been registered!");
      }
    }
      }
    else
      {
      echo 
"your password do not match!"// I am also not good in english, but I think here should be "does" not "do".
      
}
    }
  else
    {
    echo 
"Please fill in <b>all</b> fields!";
    }
  }
?>
<p>
<form action="register.php" method="POST">
<table>
<tr>
<td>
first name
</td>
<td>
<input type="text" name="firstname" value="<?php echo $firstname?>">
</td>
</tr>
<tr>
<td>
last name
</td>
<td>
<input type="text" name="lastname" value="<?php echo $lastname?>">
</td>
</tr>
<tr>
<td>
Email
</td>
<td>
<input type="email" name="email" value="<?php echo $email?>">
</td>
</tr>
<tr>
<td>
password
</td>
<td>
<input type="password" name="password">
</td>
</tr>
<tr>
<td>
Repeat password
</td>
<td>
<input type="password" name="repeatpassword">
</td>
</tr>
</table>
<input type="submit" name="submit" value="Register">
</form>
</p>
<body></html>
For security reasons, you should use "mysql_real_escape_string()" function on data executed in SQL queries, for example:
PHP Code:
$email mysql_real_escape_string(strtolower(strip_tags($_POST['email']))); 
Also for security, you should not post your login data on public places (I "xxx" it).


But some better, in my opinion, approach would be using a separate function:
PHP Code:
<html><body>
// E-mail and password form thingy to login
<form action='login.php' method='POST'>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='email' name='email' value="">
<input type='password' name='password'>
<input type='submit' value='log in'><br><br><hr>
</form>
echo "<h1>Sign up</h1>";

<?php
function RegisterUser()
  {
  global 
$firstname$lastname$email// It could be better solved

  
$submit = empty($_POST['submit']) ? '' $_POST['submit'];

  
//form data
  
$firstname strip_tags($_POST['firstname']);
  
$SQLfirstname mysql_real_escape_string($firstname);
  
$lastname strip_tags($_POST['lastname']);
  
$SQLlastname mysql_real_escape_string($lastname);
  
$email =strtolower(strip_tags($_POST['email']));
  
$SQLemail mysql_real_escape_string($email);
  
$password =md5 (strip_tags($_POST['password']));
  
$SQLpassword mysql_real_escape_string($password);
  
$repeatpassword =md5 (strip_tags($_POST['repeatpassword']));
  
$date date("Y-m-d");

  
  if (!isset(
$submit))
    return 
'';

  
//open database
  
$connect mysql_connect("xxx","xxx","");
  
mysql_select_db("xxx"); //select database

  
$namecheck mysql_query("SELECT email FROM users WHERE email='$SQLemail'");
  
$count mysql_num_rows($namecheck);

  if (
$count!=0)
    return 
"Email already in use!";

  
//check for existance
  
if (empty($firstname) || empty($lastname) || empty($email) || empty($password) || empty($repeatpassword))
    return 
"Please fill in <b>all</b> fields!";

  if (
$password != $repeatpassword)
    return 
"Your password does not match!";

  
//check char lenght of email, firstname and lastname
  
if (strlen($email)>25||strlen($firstname)>25||strlen($lastname)>25)
    return 
"Length of email or firstname or lastname is too long!";

  
//check password length
  
if (strlen($password)>25||strlen($password)<6)
    return 
"Password must be between 6 and 25 charaters.";

  
//register the user!

  // encript password
  
$password md5 ($password);
  
$repeatpassword md5 ($repeatpassword);
  
$queryreg mysql_query("
    INSERT INTO users VALEU ('','
$SQLfirstname','$SQLemail','$SQLpassword','$date')
    "
);
  
  return 
true;
  }



$Result RegisterUser();
if(
$Result === true// This means successful
  
echo "You have been registered!"// should not be die(), what about ending tags?
else if(!empty($Result)) // This means some error message
  
echo $Result;


global 
$firstname$lastname$email;
// register box
?>
<p>
<form action="register.php" method="POST">
<table>
<tr>
<td>
first name
</td>
<td>
<input type="text" name="firstname" value="<?php echo $firstname?>">
</td>
</tr>
<tr>
<td>
last name
</td>
<td>
<input type="text" name="lastname" value="<?php echo $lastname?>">
</td>
</tr>
<tr>
<td>
Email
</td>
<td>
<input type="email" name="email" value="<?php echo $email?>">
</td>
</tr>
<tr>
<td>
password
</td>
<td>
<input type="password" name="password">
</td>
</tr>
<tr>
<td>
Repeat password
</td>
<td>
<input type="password" name="repeatpassword">
</td>
</tr>
</table>
<input type="submit" name="submit" value="Register">
</form>
</p>
?>
</body></html>

Last edited by eSelix; 06-03-2012 at 09:44 AM.
 
Old 06-03-2012, 02:37 AM   #4
nothing07
LQ Newbie
 
Registered: Jun 2012
Posts: 11

Original Poster
Rep: Reputation: Disabled
Thanks m8, i followed your advices and everything its working fine now Thank you very much and I am also new here, so could you tell me the code to get my scrip in CODE: like yours
 
Old 06-03-2012, 09:43 AM   #5
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
To use CODE tags, you need to click an icon on advanced editor toolbar which look like "#". Or faster by enclosing text [CODE]some text[/CODE]. You can also use [PHP] tag insted of [CODE].
 
Old 06-03-2012, 02:11 PM   #6
nothing07
LQ Newbie
 
Registered: Jun 2012
Posts: 11

Original Poster
Rep: Reputation: Disabled
Thanx again

Last edited by nothing07; 06-03-2012 at 03:20 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse error: syntax error, unexpected '@' in php code minipro Programming 1 06-14-2011 04:33 AM
Parse error: syntax error, unexpected T_STRING in /home/dodonet2/public_html/includes bestbuddy Linux - Newbie 8 01-10-2010 08:31 PM
What is a Parse Error: syntax unexpected $end in Viewtopic_body.html.php sonia510 Programming 2 10-01-2009 04:43 PM
PHP Error Parse error: parse error, unexpected $ in /home/content/S/k/i/SkinCare4U/h CowanServices Programming 2 12-09-2008 08:26 PM
Parse error: parse error, unexpected $ in /home/content/d/o/m/domain/html/addpuppy2.p Scooby-Doo Programming 3 10-25-2007 09:41 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration