473,406 Members | 2,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 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 19005
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.