Forum Moderators: coopster

Message Too Old, No Replies

Parse error: unexpected $end

         

Orangutang

3:10 pm on Jul 18, 2010 (gmt 0)

10+ Year Member



Hi,

I'm getting the following parse error on my reg script. I've checked all the syntax a number of times without resolving. I'm hoping its something simple.

Parse error: syntax error, unexpected $end in C:\xampp\htdocs\testingsite\adduser.php on line 38

Please see the code below, its not that long: :-)

<?php
session_start();
$mysql = mysql_connect("localhost","lala","lala") or die ("Could not connect to mysql");
mysql_select_db("mybusiness",$mysql) or die ("No database");

$username = strtolower(trim($_POST['username']));
$password = $_POST['password'];
$password2 = $_POST['password2'];

$checkusername = mysql_query("SELECT `username` FROM `clients` " . "WHERE `username` = '" . $_POST['username'] . "'",$mysql);

if(mysql_num_rows($checkusername) == "1")
{
echo "Username taken, please try again<p>";
include "signup.php";
exit;
}

if(strlen($_POST['username'] > 32))
{
echo "The username is too long<p>";
include "signup.php";
exit;

if($_POST['password'] != $_POST['password2'])
{
echo "Passwords do not match, please try again<p>";
include "signup.php";
exit;
}

$password = md5($_POST['password']);
mysql_query("INSERT INTO `clients` (`username`,`password`) " . "VALUES ('" . $username . "','" . $password . "')",$mysql);
$_SESSION['user'] = $username;
header("Location: index.php");
?>

Many thanks

enigma1

3:59 pm on Jul 18, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You are missing a closing bracket right after this code

if(strlen($_POST['username'] > 32))
{
echo "The username is too long<p>";
include "signup.php";
exit;

} // Missing

lammert

3:59 pm on Jul 18, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



We normally don't like "do my homework" and "search my error" type of questions, but these $end errors are often difficult to find because the origin of it can be throughout the script, not just at the end. Most of the time it is an unmatched ", ', ( or {. In this case, I think the problem is in one of your if statements:

{ 
echo "The username is too long<p>";
include "signup.php";
exit;


should be probably

{ 
echo "The username is too long<p>";
include "signup.php";
exit;
}


<edit>Arghhh, enigma1 was just a few seconds faster</edit>

Orangutang

4:10 pm on Jul 18, 2010 (gmt 0)

10+ Year Member



Hi, thanks that sorted it.

Appreciate what your saying about the homework and search my errors posts.

No probs and thanks again.