/    Sign up×
Community /Pin to ProfileBookmark

Cant find where this error is!

I am receiving an unexpected T_STRING, expecting ‘,’ or ‘;’ on line 164 but I dont have that many lines in my code. I cant figure out where it is coming from. Here is my code:

<?php
// This is the registration page for the site.
// This file both displays and processes the registration form.
// Require the configuration before any PHP code as the configuration controls error reporting:
require (‘/includes/config.inc.php’);
// The config file also starts the session.
// Include the header file:
include (‘/includes/header.html’);
// Require the database connection:
require (MYSQL);
// For storing registration errors:
$reg_errors = array();
// Check for a form submission
if ($_SERVER[‘REQUEST_METHOD’] == ‘POST’) {
// Check for a first name:
if (preg_match (‘/^[A-Z ‘.-]{2,20}$/i’, $_
POST[‘first_name’])) {
$fn = mysqli_real_escape_string ($dbc, $_POST[‘first_name’]);
} else {
$reg_errors[‘first_name’] = ‘Please enter your first name!’;
}
// Check for a last name:
if (preg_match (‘/^[A-Z ‘.-]{2,40}$/i’, $_
POST[‘last_name’])) {
$ln = mysqli_real_escape_string ($dbc, $_POST[‘last_name’]);
} else {
$reg_errors[‘last_name’] = ‘Please enter your last name!’;
}
// Check for an email address:
if (filter_var($_
POST[’email’], FILTER_VALIDATE_EMAIL)) {
$e = mysqli_real_escape_string ($dbc, $_POST[’email’]);
} else {
$reg_errors[’email’] = ‘Please enter a valid email address!’;
}
// Make sure the email address is available:
$q = “SELECT email FROM users WHERE email=’$e'”;
$r = mysqli_query ($dbc, $q);
// Get the number of rows returned:
$rows = mysqli_num_rows($r);
if ($rows == 0) { // No problems!
// New query, updated for PayPal integration:
$q = “INSERT INTO users (email, first_name, last_name) VALUES (‘$e’, ‘$fn’, ‘$ln’)”;
$r = mysqli_query ($dbc, $q);
if (mysqli_affected_rows($dbc) == 1) { // If it ran OK.
// Get the user ID:
// Store the new user ID in the session:
$uid = mysqli_insert_id($dbc);
$_
SESSION[‘reg_user_id’] = $uid;
// Display a thanks message:
echo “<h3>Thanks!</h3><p>Thank you for registering! To complete the process,
please now click the button below so that you may pay for your site access via
PayPal. The cost is $10 (US) per year.</p>”
// PayPal link
echo ‘<form action=”https://www.sandbox.paypal.com/cgi-bin/webscr” method=”post”>
<input type=”hidden” name=”cmd” value=”_s-xclick”>
<input type=”hidden” name=”custom” value=”‘ . $uid . ‘”>
<input type=”hidden” name=”email” value=”‘ . $e . ‘”>
<input type=”hidden” name=”hosted_button_id” value=”8YW8FZDELF296″>
<input type=”image” src=”https://www.sandbox.paypal.com/en_US/i/btn/btn_subscribeCC_LG.gif” border=”0″ name=”submit” alt=”PayPal – The safer, easier way to pay online!”>
<img alt=”” border=”0″ src=”https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif” width=”1″ height=”1″>
</form>
// Send a separate email?
$body = “Thank you for registering at <whatever site>. Blah. Blah. Blah.nn”;
mail($_
POST[’email’], ‘Registration Confirmation’, $body, ‘From: [email][email protected][/email]‘);
// Finish the page:
// Include the HTML footer.
include (‘/includes/footer.html’);
// Stop the page.
exit();
} else { // If it did not run OK.
trigger_error(‘You could not be registered due to a system error.
We apologize for any inconvenience.’);
if ($rows == 1) { // Both are taken.
$reg_errors[’email’] = ‘This email address has already been registered.
}}
// Get row:
$row = mysqli_fetch_array($r, MYSQLI_NUM);
if( ($row[0] == $_POST[’email’]))
{ // Both match.
$reg_errors[’email’] = ‘This email address has already been registered.
} elseif ($row[0] == $_
POST[’email’]) { // Email match.
$reg_errors[’email’] = ‘This email address has already been registered.
} // End of $rows == 2 ELSE.
} // End of $rows == 0 IF.
} // End of empty($reg_errors) IF.
{
// End of the main form submission conditional.
// Need the form functions script, which defines create_form_input():
require (‘/home/sportd5/includes/form_function.inc.php’);?>
<h3>Register</h3>
<p>Access to the site’s content is available to registered users at
a cost of $10.00 (US) per year. Use the form below to begin the registration process.
<strong>Note: All fields are required.</strong> After completing this form, you’ll be
presented with the opportunity to securely pay for your yearly subscription via
<a href=”http://www.paypal.com”>PayPal</a>.</p>
<form action=”register.php” method=”post”
accept-charset=”utf-8″ style=”padding-left:100px”>
<p><label for=”first_name”><strong>First Name</strong></label><br />
<?php create_form_input(‘first_name’, ‘text’, $reg_errors); ?>
</p>
<p><label for=”last_name”><strong>Last Name</strong></label><br />
<?php create_form_input(‘last_name’, ‘text’, $reg_errors); ?>
</p>
<p><label for=”email”><strong>Email Address</strong></label><br />
<?php create_form_input(’email’, ‘text’, $reg_errors); ?>
</p>
<input type=”submit” name=”submit_button” value=”Next &rarr;” id=”submit_button” class=”formbutton” />
</form>
<?php
// Include the HTML footer:
include (‘/includes/footer.html’);?>

Any advise or help will be appreciated.

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@NogDogFeb 26.2012 — Are you sure the error message is not pointing to that line number in one of the included/required files?

PS: Please wrap your posted code in this forum's [noparse][code=php]...[/code][/noparse] tags, which will make it much easier for us to read.
Copy linkTweet thisAlerts:
@mccoauthorFeb 26.2012 — I am receiving an unexpected T_STRING, expecting ',' or ';' on line 164 but I dont have that many lines in my code. I cant figure out where it is coming from. Here is my code:
[code=php]
<?php
// This is the registration page for the site.
// This file both displays and processes the registration form.
// Require the configuration before any PHP code as the configuration controls error reporting:
require ('/includes/config.inc.php');
// The config file also starts the session.
// Include the header file:
include ('/includes/header.html');
// Require the database connection:
require (MYSQL);
// For storing registration errors:
$reg_errors = array();
// Check for a form submission
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Check for a first name:
if (preg_match ('/^[A-Z '.-]{2,20}$/i', $_POST['first_name'])) {
$fn = mysqli_real_escape_string ($dbc, $_POST['first_name']);
} else {
$reg_errors['first_name'] = 'Please enter your first name!';
}
// Check for a last name:
if (preg_match ('/^[A-Z '.-]{2,40}$/i', $_POST['last_name'])) {
$ln = mysqli_real_escape_string ($dbc, $_POST['last_name']);
} else {
$reg_errors['last_name'] = 'Please enter your last name!';
}
// Check for an email address:
if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
$e = mysqli_real_escape_string ($dbc, $_POST['email']);
} else {
$reg_errors['email'] = 'Please enter a valid email address!';
}
// Make sure the email address is available:
$q = "SELECT email FROM users WHERE email='$e'";
$r = mysqli_query ($dbc, $q);
// Get the number of rows returned:
$rows = mysqli_num_rows($r);
if ($rows == 0) { // No problems!
// New query, updated for PayPal integration:
$q = "INSERT INTO users (email, first_name, last_name) VALUES ('$e', '$fn', '$ln')";
$r = mysqli_query ($dbc, $q);
if (mysqli_affected_rows($dbc) == 1) { // If it ran OK.
// Get the user ID:
// Store the new user ID in the session:
$uid = mysqli_insert_id($dbc);
$_SESSION['reg_user_id'] = $uid;
// Display a thanks message:
echo "<h3>Thanks!</h3><p>Thank you for registering! To complete the process,
please now click the button below so that you may pay for your site access via
PayPal. The cost is $10 (US) per year.</p>"
// PayPal link
echo '<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="custom" value="' . $uid . '">
<input type="hidden" name="email" value="' . $e . '">
<input type="hidden" name="hosted_button_id" value="8YW8FZDELF296">
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
// Send a separate email?
$body = "Thank you for registering at <whatever site>. Blah. Blah. Blah.nn";
mail($_POST['email'], 'Registration Confirmation', $body, 'From: [email][email protected][/email]');
// Finish the page:
// Include the HTML footer.
include ('/includes/footer.html');
// Stop the page.
exit();
} else { // If it did not run OK.
trigger_error('You could not be registered due to a system error.
We apologize for any inconvenience.');
if ($rows == 1) { // Both are taken.
$reg_errors['email'] = 'This email address has already been registered.
}}
// Get row:
$row = mysqli_fetch_array($r, MYSQLI_NUM);
if( ($row[0] == $_POST['email']))
{ // Both match.
$reg_errors['email'] = 'This email address has already been registered.
} elseif ($row[0] == $_POST['email']) { // Email match.
$reg_errors['email'] = 'This email address has already been registered.
} // End of $rows == 2 ELSE.
} // End of $rows == 0 IF.
} // End of empty($reg_errors) IF.
{
// End of the main form submission conditional.
// Need the form functions script, which defines create_form_input():
require ('/home/sportd5/includes/form_function.inc.php');?>
<h3>Register</h3>
<p>Access to the site's content is available to registered users at
a cost of $10.00 (US) per year. Use the form below to begin the registration process.
<strong>Note: All fields are required.</strong> After completing this form, you'll be
presented with the opportunity to securely pay for your yearly subscription via
<a href="http://www.paypal.com">PayPal</a>.</p>
<form action="register.php" method="post"
accept-charset="utf-8" style="padding-left:100px">
<p><label for="first_name"><strong>First Name</strong></label><br />
<?php create_form_input('first_name', 'text', $reg_errors); ?>
</p>
<p><label for="last_name"><strong>Last Name</strong></label><br />
<?php create_form_input('last_name', 'text', $reg_errors); ?>
</p>
<p><label for="email"><strong>Email Address</strong></label><br />
<?php create_form_input('email', 'text', $reg_errors); ?>
</p>
<input type="submit" name="submit_button" value="Next &rarr;" id="submit_button" class="formbutton" />
</form>
<?php
// Include the HTML footer:
include ('/includes/footer.html');?>
[/code]

Any advise or help will be appreciated.[/QUOTE]


sorry about that
Copy linkTweet thisAlerts:
@CharlesFeb 26.2012 — It's likely that the error is in one of your include files, one with 164 or more lines. Look more closely. The error message should have included the name of the file.
Copy linkTweet thisAlerts:
@NogDogFeb 26.2012 — There were several parse errors just in the code you posted, mostly missing terminal semi-colons and/or closing quotes. (A decent code editor with built-in syntax-checking can save you a lot of time.)
[code=php]
<?php
// This is the registration page for the site.
// This file both displays and processes the registration form.
// Require the configuration before any PHP code as the configuration controls error reporting:
require ('/includes/config.inc.php');
// The config file also starts the session.
// Include the header file:
include ('/includes/header.html');
// Require the database connection:
require (MYSQL);
// For storing registration errors:
$reg_errors = array();
// Check for a form submission
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Check for a first name:
if (preg_match ('/^[A-Z '.-]{2,20}$/i', $_POST['first_name'])) {
$fn = mysqli_real_escape_string ($dbc, $_POST['first_name']);
} else {
$reg_errors['first_name'] = 'Please enter your first name!';
}
// Check for a last name:
if (preg_match ('/^[A-Z '.-]{2,40}$/i', $_POST['last_name'])) {
$ln = mysqli_real_escape_string ($dbc, $_POST['last_name']);
} else {
$reg_errors['last_name'] = 'Please enter your last name!';
}
// Check for an email address:
if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
$e = mysqli_real_escape_string ($dbc, $_POST['email']);
} else {
$reg_errors['email'] = 'Please enter a valid email address!';
}
// Make sure the email address is available:
$q = "SELECT email FROM users WHERE email='$e'";
$r = mysqli_query ($dbc, $q);
// Get the number of rows returned:
$rows = mysqli_num_rows($r);
if ($rows == 0) { // No problems!
// New query, updated for PayPal integration:
$q = "INSERT INTO users (email, first_name, last_name) VALUES ('$e', '$fn', '$ln')";
$r = mysqli_query ($dbc, $q);
if (mysqli_affected_rows($dbc) == 1) { // If it ran OK.
// Get the user ID:
// Store the new user ID in the session:
$uid = mysqli_insert_id($dbc);
$_SESSION['reg_user_id'] = $uid;
// Display a thanks message:
echo "<h3>Thanks!</h3><p>Thank you for registering! To complete the process,
please now click the button below so that you may pay for your site access via
PayPal. The cost is $10 (US) per year.</p>";
// PayPal link
echo '<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="custom" value="' . $uid . '">
<input type="hidden" name="email" value="' . $e . '">
<input type="hidden" name="hosted_button_id" value="8YW8FZDELF296">
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>';
// Send a separate email?
$body = "Thank you for registering at <whatever site>. Blah. Blah. Blah.nn";
mail($_POST['email'], 'Registration Confirmation', $body, 'From: [email][email protected][/email]');
// Finish the page:
// Include the HTML footer.
include ('/includes/footer.html');
// Stop the page.
exit();
} else { // If it did not run OK.
trigger_error('You could not be registered due to a system error.
We apologize for any inconvenience.');
if ($rows == 1) { // Both are taken.
$reg_errors['email'] = 'This email address has already been registered.';
}}
// Get row:
$row = mysqli_fetch_array($r, MYSQLI_NUM);
if( ($row[0] == $_POST['email']))
{ // Both match.
$reg_errors['email'] = 'This email address has already been registered.';
} elseif ($row[0] == $_POST['email']) { // Email match.
$reg_errors['email'] = 'This email address has already been registered.';
} // End of $rows == 2 ELSE.
} // End of $rows == 0 IF.
} // End of empty($reg_errors) IF.
{
// End of the main form submission conditional.
// Need the form functions script, which defines create_form_input():
require ('/home/sportd5/includes/form_function.inc.php');?>
<h3>Register</h3>
<p>Access to the site's content is available to registered users at
a cost of $10.00 (US) per year. Use the form below to begin the registration process.
<strong>Note: All fields are required.</strong> After completing this form, you'll be
presented with the opportunity to securely pay for your yearly subscription via
<a href="http://www.paypal.com">PayPal</a>.</p>
<form action="register.php" method="post"
accept-charset="utf-8" style="padding-left:100px">
<p><label for="first_name"><strong>First Name</strong></label><br />
<?php create_form_input('first_name', 'text', $reg_errors); ?>
</p>
<p><label for="last_name"><strong>Last Name</strong></label><br />
<?php create_form_input('last_name', 'text', $reg_errors); ?>
</p>
<p><label for="email"><strong>Email Address</strong></label><br />
<?php create_form_input('email', 'text', $reg_errors); ?>
</p>
<input type="submit" name="submit_button" value="Next &rarr;" id="submit_button" class="formbutton" />
</form>
<?php
// Include the HTML footer:
include ('/includes/footer.html');?>
[/code]
Copy linkTweet thisAlerts:
@spufiFeb 26.2012 — I popped the code into my IDE and got flags for 8 errors. I know copy/pasting code can change the formatting from what you have in your text editor, but if the code is exactly like how you have it, that's brutal to read through.

Fixes below. FYI, you have repeated statements that are missing the closing quote and semicolon.

1.
<i>
</i>echo "&lt;h3&gt;Thanks!&lt;/h3&gt;&lt;p&gt;Thank you for registering! To complete the process,
please now click the button below so that you may pay for your site access via
PayPal. The cost is $10 (US) per year.&lt;/p&gt;";


2.
<i>
</i>echo '&lt;form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"&gt;
&lt;input type="hidden" name="cmd" value="_s-xclick"&gt;
&lt;input type="hidden" name="custom" value="' . $uid . '"&gt;
&lt;input type="hidden" name="email" value="' . $e . '"&gt;
&lt;input type="hidden" name="hosted_button_id" value="8YW8FZDELF296"&gt;
&lt;input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"&gt;
&lt;img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"&gt;
&lt;/form&gt;';


3.
<i>
</i>if ($rows == 1) { // Both are taken.
$reg_errors['email'] = 'This email address has already been registered.';


4.
<i>
</i>if( ($row[0] == $_POST['email']))
{ // Both match.
$reg_errors['email'] = 'This email address has already been registered.';
} elseif ($row[0] == $_POST['email']) { // Email match.
$reg_errors['email'] = 'This email address has already been registered.';


The last line code of is giving me an unexpected EOF error, but hell if I'm going to weed through that code to find the fix. ?

Here's the download link for the IDE I use since whatever you are using doesn't seem to be helping.

http://www.eclipse.org/downloads/packages/eclipse-php-developers/heliosr
Copy linkTweet thisAlerts:
@spufiFeb 26.2012 — And maybe it's me, but I would rather do this section like this.

<i>
</i>// Display a thanks message:
?&gt;
&lt;h3&gt;Thanks!&lt;/h3&gt;
&lt;p&gt;Thank you for registering! To complete the process, please now click the button below so that you may pay for your site access via PayPal. The cost is $10 (US) per year.
&lt;/p&gt;
&lt;form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"&gt;
&lt;input type="hidden" name="cmd" value="_s-xclick"&gt;
&lt;input type="hidden" name="custom" value="&lt;?php $uid ?&gt;"&gt;
&lt;input type="hidden" name="email" value="&lt;?php $e ?&gt;"&gt;
&lt;input type="hidden" name="hosted_button_id" value="8YW8FZDELF296"&gt;
&lt;input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"&gt;
&lt;img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"&gt;
&lt;/form&gt;
&lt;?php


Also, isn't the if and the elseif the same?

<i>
</i>if( ($row[0] == $_POST['email']))
{ // Both match.
$reg_errors['email'] = 'This email address has already been registered.';
} elseif ($row[0] == $_POST['email']) { // Email match.
$reg_errors['email'] = 'This email address has already been registered.';
Copy linkTweet thisAlerts:
@mccoauthorFeb 27.2012 — Thanks for your help guys. As you can see I am still in the beginning stages of my php development. That was edited on regular notepad that is why I could not see the errors. I recently downloaded notepad++ and it is so much easier to see everything now. Thanks again for your help and I am sure I will have other questions as I put together my ebook site.
×

Success!

Help @mcco spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...