423,850 Members | 1,074 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,850 IT Pros & Developers. It's quick & easy.

Parse error: parse error, unexpected $end

P: n/a
I recently created a script for user verification, solved my emailing
issues, and then re-created the script in order to work well with the
new PHP 5 that I installed on my server. After submitting user
information into my creation script, I get the following error from the
page that is suppose to insert the user data into the database, create
a code, then send an email out for verification.

Parse error: parse error, unexpected $end in
c:\wamp\www\thread\create\add2tbl.php on line 31

Below are the files in which I am using:

add2tbl.php

<?php
require "mailfunctions.php";
$username = $_POST['username'];
$md5password2 = md5($_POST['pass2']);
$email = $_POST['email'];
$md5password = md5($_POST['pass']);
if(isset($_POST['username'])) {
if ($md5password == $md5password2) {
$db = dbc();
$code = codegen();
$user = insertuser($username, $md5password, $email, $code);
if ($user == FALSE) {
die("There has been an error in adding you to the Database. Please
EMail the admin.");
}
else {
echo "<b>Passwords do not match!</b> ";
}
include("/top.html");

$mail = mailauth($username);
if ($mail) {
echo '
<p class = "subtitle">Success! Check your email.</p>';
} else {
echo '
<p class = "subtitle">We are sorry. The request did not go through
successfully due to an error in the Mail server. Please contact the
Admin.</p>';

}
include("/bottom.html");
}
?>

mailfunctions.php

<?php
function dbc() {
mysql_connect(localhost, "root");
mysql_select_db("ehartwig1");
return TRUE;
}
function codegen() {
$code = rand(10000000000000,999999999999999);
return $code;
}
function insertuser($name,$md5password,$email,$code) {
$query = "INSERT INTO threadauth (username, password, email,
authcode) VALUES ('{$name}','{$md5password}','{$email}', '{$code}') or
return(FALSE)";
$result = mysql_db_query($query);
return $result;
}
function md5fetcher($name) {
$query = mysql_query("SELECT password FROM threadauth WHERE
username='".$name."');
$result = mysql_fetch_array($query);
return $result['password'];
}
function mailfetcher($name) {
$query = mysql_query("SELECT email FROM threadauth WHERE
username='".$name."');
$result = mysql_fetch_array($query);
return $result['email'];
}

function codefetcher($name) {
$query = mysql_query("SELECT authcode FROM threadauth WHERE
username='".$name."');
$result = mysql_fetch_array($query);
return $result['authcode'];
}
function codecheck($name, $authcode) {
$code = codefetcher($name);
if ($code == $authcode) {
return TRUE;
}
else {
return FALSE;
}
}
function mailauth($username) {
$email = mailfetcher($username);
$code = codefetcher($username);
$message = "
Subscription Request
You have requested to receive a membership. You must follow the
link and insert the code provided in order to activate your account.

Username: {$username}
Activation Code: {$code}
http://www.ehartwig.com/thread/activate.php?authcode={$code}&username={$username}

Thank You.";
mail($recipient, $subject, $message) or return(FALSE);
return(TRUE);
}
?>

How can I solve this problem or what should I do differently?

Nov 5 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Ehartwig wrote:
I recently created a script for user verification, solved my emailing
issues, and then re-created the script in order to work well with the
new PHP 5 that I installed on my server. After submitting user
information into my creation script, I get the following error from the
page that is suppose to insert the user data into the database, create
a code, then send an email out for verification.

Parse error: parse error, unexpected $end in
c:\wamp\www\thread\create\add2tbl.php on line 31

Below are the files in which I am using:

add2tbl.php

<?php
require "mailfunctions.php";
$username = $_POST['username'];
$md5password2 = md5($_POST['pass2']);
$email = $_POST['email'];
$md5password = md5($_POST['pass']);
if(isset($_POST['username'])) {
if ($md5password == $md5password2) {
$db = dbc();
$code = codegen();
$user = insertuser($username, $md5password, $email, $code);
if ($user == FALSE) {
die("There has been an error in adding you to the Database. Please
EMail the admin.");
}
else {
echo "<b>Passwords do not match!</b> ";
}
include("/top.html");

$mail = mailauth($username);
if ($mail) {
echo '
<p class = "subtitle">Success! Check your email.</p>';
} else {
echo '
<p class = "subtitle">We are sorry. The request did not go through
successfully due to an error in the Mail server. Please contact the
Admin.</p>';

}
include("/bottom.html");
}
?>
<snip>
You are missing a closing bracket in the add2tbl.php file.
Based on the layout, my guess would be that it should come after: if ($user == FALSE) {
die("There has been an error in adding you to the Database.

Please EMail the admin.");

Even so, could just as easily go elsewhere as your indenting is pretty
inconsistent (I didn't study the code).

Grz, J.
Nov 5 '05 #2

P: n/a
In article <43**********************@news.wanadoo.nl>,
jr*********@jokeaday.net (Juliette) wrote:

You are missing a closing bracket in the add2tbl.php file.
Based on the layout, my guess would be that it should come after:
> if ($user == FALSE) {
> die("There has been an error in adding you to the
Database. Please EMail the admin.");

Even so, could just as easily go elsewhere as your indenting is
pretty inconsistent (I didn't study the code).

Grz, J.


I'm quite sure this has been debated many times before, but I have a
thing in my head about the way neophyte web programmers lay out their
code.

In the olden days ;-) we used to do it like this,

if (statement);
{
if (statement);
{
do something;
}
else
{
do something else;
}
}
else

etc etc etc

Most sensible PFE's will support this, but you can see straight away if
you have unbalanced parenthesis.

Now, because I'm an old git, and I've always done it that way, I'll
continue, but what is the reasoning behind hiding a curly bracket at the
end of a statement ?

</2d>


- Steve
Nov 5 '05 #3

P: n/a
In the nowa days i do it a bit other way but still it is more readeble
than the example above

Nov 5 '05 #4

P: n/a
Now I am receiving a new error on line 19:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE,
expecting T_STRING or T_VARIABLE or T_NUM_STRING in
\thread\create\mailfunctions.php on line 19

function md5fetcher($name) {
$query = mysql_query("SELECT password FROM threadauth WHERE
username='".$name."');
$result = mysql_fetch_array($query);
return $result['password'];

line 19 = "return $result['password'];

Your help has been appreciated,
--Erich Hartwig

Nov 5 '05 #5

P: n/a
Ehartwig said the following on 05/11/2005 17:48:
Now I am receiving a new error on line 19:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE,
expecting T_STRING or T_VARIABLE or T_NUM_STRING in
\thread\create\mailfunctions.php on line 19

function md5fetcher($name) {
$query = mysql_query("SELECT password FROM threadauth WHERE
username='".$name."');
$result = mysql_fetch_array($query);
return $result['password'];


Check your opening/closing quote pairing...
--
Oli
Nov 5 '05 #6

P: n/a
Steve wrote:
In article <43**********************@news.wanadoo.nl>,
jr*********@jokeaday.net (Juliette) wrote:
You are missing a closing bracket in the add2tbl.php file.
Based on the layout, my guess would be that it should come after:
> if ($user == FALSE) {
> die("There has been an error in adding you to the


Database.
Please EMail the admin.");

Even so, could just as easily go elsewhere as your indenting is
pretty inconsistent (I didn't study the code).

Grz, J.

I'm quite sure this has been debated many times before, but I have a
thing in my head about the way neophyte web programmers lay out their
code.

In the olden days ;-) we used to do it like this,

if (statement);
{
if (statement);
{
do something;
}
else
{
do something else;
}
}
else

etc etc etc

Most sensible PFE's will support this, but you can see straight away if
you have unbalanced parenthesis.

Now, because I'm an old git, and I've always done it that way, I'll
continue, but what is the reasoning behind hiding a curly bracket at the
end of a statement ?

</2d>


- Steve


That was one of the ways I've seen. Personally I liked

if (statement)
{
do something;
{
else
{
do something else;
}

Makes it very easy to check your indentation and match braces. But the
one I really don't like seems to be quite popular in PHP and Java:

if (statement) {
do something;
{
else {
do something else;
}
Sure, it takes fewer lines, but it's easy to mismatch braces.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 22 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.