472,955 Members | 2,313 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,955 software developers and data experts.

Parse error: parse error, unexpected $end

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
6 18954
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: sky2070 | last post by:
Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting ')' in c:\inetpub\wwwroot\session.php on line 19 can anyone tell me what is wrong with this code??? <? // Define the Session...
1
by: Janwillem Borleffs | last post by:
Q: I'm getting an unexpected $ or $end parse/syntax error, what's causing this? A: This is caused when an expression is started with an opening brace, but the closing brace is omitted. ...
8
by: Wescotte | last post by:
The error message Parse error: syntax error, unexpected $end in FILE on line X is one I run into frequently and I know the cause is I missed an ending quote. Is there an easy way to determine...
4
mikeinspain
by: mikeinspain | last post by:
Keep getting this error! Parse error: syntax error, unexpected $end in /home/9144/domains/cbweb.co.uk/html/faq_finance.php on line 139 PHP Below.. Script was working 1 minute and copied the...
3
by: bb nicole | last post by:
Below is the code i create when i click on the job title hyperlink, it will display the job information where call from database. But the error message is: Parse error: parse error, unexpected $end...
1
by: soidariti | last post by:
database error - parse error, unexpected $, expecting kEND AddUserAuthorisationToUsers.rb migration file 1. class AddUserAuthorisationToUsers < ActiveRecord::Migration 2. def self.up ...
9
by: ajd335 | last post by:
Hi all... I am getting an error Parse error: syntax error, unexpected $end in http:/..... on line 117...(117 is the EOF).. can you plz help me out..I have checked out for the < , > ,{ ,} etc.......
2
by: Lawrence Krubner | last post by:
Imagine a template system that works by getting a file, as a string, and then putting it through eval(), something like this: $formAsString = $controller->command("readFileAndReturnString",...
9
akohistani
by: akohistani | last post by:
I am having Parse error problem with my newly purchased Php upload script I have uploaded the script and I get the error below Parse error: syntax error, unexpected $end in URL/functions.php on...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.