Parse error on a line that doesn't exist..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Parse error on a line that doesn't exist..

Post by d3ad1ysp0rk »

Code: Select all

<?PHP
if($_POST['act']=="process" && isset($_POST['username']) && $_POST['password']==$_POST['password2'] && isset($_POST['email']))
{
   $dbuser="*****";
   $dbpass="*****";
   $dbname="****";
   $dbconnect=mysql_connect(localhost,$dbuser,$dbpass) or die("Unable to connect.");
   mysql_select_db($dbname) or die("Unable to select database");
   $isql = "INSERT INTO `newtable` (username, password, email) VALUES ($username, $password, $email)";
   mysql_query($isql);
}
else
{
   echo <<<EOT
   <html>
   <head>
   <title>Register</title>
   </head>
   <body>
   <form action="register.php" method="post" name="registerform">
   Email Address: <input type="text" name="email"><br>
   Username: <input type="text" name="username"><br>
   Password: <input type="text" name="password"><br>
   Password Again: <input type="password" name="password2"><br>
   <input type="submit" value="Register!" name="submit2">
   </form>
   </body>
   </html>
   EOT;
}
?> //line 31
Parse error: parse error in /home/des404/public_html/lscript/register.php on line 32
anyone?? im guessing it's easy since it's a parse error, but i need an extra set of eyes for this..

thanks
lc
Forum Contributor
Posts: 188
Joined: Tue Apr 23, 2002 6:45 pm
Location: Netherlands

Post by lc »

Can't see an error in the regular php but what is that EOT thing??? I've never seen it before???
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

Maybe this:

Code: Select all

$dbconnect=mysql_connect(localhost,$dbuser,$dbpass) or die("Unable to connect.");
localhost is not a variable, so you'll still need the quotes. Fix:

Code: Select all

$dbconnect=mysql_connect("localhost",$dbuser,$dbpass) or die("Unable to connect.");
-Nay
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You've got spaces / a tab before the end of the heredoc (EOT;), and that could cause the error.

Mac
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

As twigletmac said:

Quote from manual
It is very important to note that the line with the closing identifier contains no other characters, except possibly a semicolon (;). That means especially that the identifier may not be indented, and there may not be any spaces or tabs after or before the semicolon. It's also important to realize that the first character before the closing identifier must be a newline as defined by your operating system. This is \r on Macintosh for example.

If this rule is broken and the closing identifier is not "clean" then it's not considered to be a closing identifier and PHP will continue looking for one. If in this case a proper closing identifier is not found then a parse error will result with the line number being at the end of the script.


Mark
Post Reply