473,722 Members | 2,161 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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\thr ead\create\add2 tbl.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($use rname, $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>Passwor ds do not match!</b> ";
}
include("/top.html");

$mail = mailauth($usern ame);
if ($mail) {
echo '
<p class = "subtitle">Succ ess! 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.p hp

<?php
function dbc() {
mysql_connect(l ocalhost, "root");
mysql_select_db ("ehartwig1" );
return TRUE;
}
function codegen() {
$code = rand(1000000000 0000,9999999999 99999);
return $code;
}
function insertuser($nam e,$md5password, $email,$code) {
$query = "INSERT INTO threadauth (username, password, email,
authcode) VALUES ('{$name}','{$m d5password}','{ $email}', '{$code}') or
return(FALSE)";
$result = mysql_db_query( $query);
return $result;
}
function md5fetcher($nam e) {
$query = mysql_query("SE LECT password FROM threadauth WHERE
username='".$na me."');
$result = mysql_fetch_arr ay($query);
return $result['password'];
}
function mailfetcher($na me) {
$query = mysql_query("SE LECT email FROM threadauth WHERE
username='".$na me."');
$result = mysql_fetch_arr ay($query);
return $result['email'];
}

function codefetcher($na me) {
$query = mysql_query("SE LECT authcode FROM threadauth WHERE
username='".$na me."');
$result = mysql_fetch_arr ay($query);
return $result['authcode'];
}
function codecheck($name , $authcode) {
$code = codefetcher($na me);
if ($code == $authcode) {
return TRUE;
}
else {
return FALSE;
}
}
function mailauth($usern ame) {
$email = mailfetcher($us ername);
$code = codefetcher($us ername);
$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.co m/thread/activate.php?au thcode={$code}& username={$user name}

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 19027
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\thr ead\create\add2 tbl.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($use rname, $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>Passwor ds do not match!</b> ";
}
include("/top.html");

$mail = mailauth($usern ame);
if ($mail) {
echo '
<p class = "subtitle">Succ ess! 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*********@jok eaday.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.p hp on line 19

function md5fetcher($nam e) {
$query = mysql_query("SE LECT password FROM threadauth WHERE
username='".$na me."');
$result = mysql_fetch_arr ay($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.p hp on line 19

function md5fetcher($nam e) {
$query = mysql_query("SE LECT password FROM threadauth WHERE
username='".$na me."');
$result = mysql_fetch_arr ay($query);
return $result['password'];


Check your opening/closing quote pairing...
--
Oli
Nov 5 '05 #6
Steve wrote:
In article <43************ **********@news .wanadoo.nl>,
jr*********@jok eaday.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*******@attgl obal.net
=============== ===
Nov 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
51392
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 class class Session { // Define the properties:
1
2293
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. Examples: if ($condition) { .... // No closing brace; the error is thrown
8
46196
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 where the inital " started? I find myself adding /* */ blocks or cutting/pasting sections of code out in order to find where the error occured. Wouldn't it it be nice if the warning message included the line in teh source where the initial quote ...
4
2195
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 script from another file that was working great. elseif (!trim($name)) { echo "<p>Ooops!, it appears that you did not enter a Name</p><p><a href='javascript: history.go(-1)'>Click here to go back</a>.</p>"; }
3
1418
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 in C:\Apache2\Apache2\htdocs\jobsearch_result.php on line 103 where line 103 is nothing, my last line is 101 <?php session_start(); ob_start();
1
6843
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 3. drop_table :users 4. 5. create_table :users, :options => 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t| 6. t.column :first_name, :string
9
4030
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.... I donno where m wrong.... <?php class S_Shipping { // Private variables.
2
3226
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", $formName); // 06-22-07 - the next commands try to import all the functions that the
9
3531
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 line 400 Someone please help me I contacted the owner of the script where I purchased he is not replying me I bought it from http://www.scubadivingcalculators.com/ and this is the url where I have uploaded the script...
0
8863
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9238
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9157
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9088
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6681
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3207
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2602
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.