Solved

parse error, unexpected T_STRING

Posted on 2006-11-29
10
245 Views
Last Modified: 2010-05-18
Hi,

Thanks for Reading.

Same Old Error, Can't Figure Out WHY it's happening.

Here is the line:
$query2 = "UPDATE customers SET logincode='".$_SESSION['logincode']."' WHERE id='".$row['id']."'";

The remaining code (around and part of is below... You can find where Line 50 is by looking at the line above.)

Thank You VERY Much for Your Help!

Respectfully,

FirstBorn

-------------------------------------
      if (empty($errors)) { // If everything's OK.

            /* Retrieve the user_id and first_name for
            that email/password combination. */
            $query = "SELECT * FROM customers WHERE email='$e';            
            $result = mysql_query ($query); // Run the query.
            $row = mysql_fetch_array ($result, MYSQL_ASSOC); // Return a record, if applicable.

            if ($row) { // A record was pulled from the database.
                  $today=date('Y-m-d');
                  if ($row[active]==1) {
                        
                        // Set the session data & redirect.
                        $_SESSION[userid] = $row[id];
                        $_SESSION[access_level] = $row[level];
                        $_SESSION[logincode] = genrandcode(40);
                        
            $query2 = "UPDATE customers SET logincode='".$_SESSION['logincode']."' WHERE id='".$row['id']."'";
                        $result2 = mysql_query ($query2); // Run the query.
                        if ($result2){
                              // Redirect the user to the page.
                              // Start defining the URL.
                              $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
                              // Check for a trailing slash.
                              if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) {
                                    $url = substr ($url, 0, -1); // Chop off the slash.
                              }
                              // Add the page.
                              $url .= '/mypage.php';
                  
                              header("Location: $url");
                              exit(); // Quit the script.

// Here is the function in an include at the BEGINNING but Not Shown section of the script:
function genrandcode($length){
      
      $library='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';

      for ($i=0; $i<$length; $i++){
            $n.=$library{rand(0,61)};
      }

      return $n;

}
------------------------------------
0
Comment
Question by:FirstBorn
  • 4
  • 4
  • 2
10 Comments
 
LVL 5

Accepted Solution

by:
dasmaer earned 500 total points
Comment Utility
where you have the line:

$query = "SELECT * FROM customers WHERE email='$e';

you forgot the closing "

try that and see what you get.
0
 
LVL 1

Author Comment

by:FirstBorn
Comment Utility
Hi dasmaer,

Thanks!

Dag-nabbit!

I KNEW there was something I was missing.

Thank You VERY Much!

Respectfully,

FirstBorn
0
 
LVL 11

Expert Comment

by:ch2
Comment Utility
I've see some errors. Let me see if you get more errors and i'll check.

Change this:
$query = "SELECT * FROM customers WHERE email='$e';

 if ($row[active]==1) {

$_SESSION[userid] = $row[id];
$_SESSION[access_level] = $row[level];
$_SESSION[logincode] = genrandcode(40);

to this:
$query = "SELECT * FROM customers WHERE email='$e'";

 if ($row['active']==1) {

$_SESSION['userid'] = $row['id'];
$_SESSION['access_level'] = $row['level'];
$_SESSION['logincode'] = genrandcode(40);
0
 
LVL 11

Expert Comment

by:ch2
Comment Utility
Changing only that won't work dasmaer. Well 4 minutes at the rubbish!

Thanks.

0
 
LVL 11

Expert Comment

by:ch2
Comment Utility
Why you accepted an answer without testing it before?
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 1

Author Comment

by:FirstBorn
Comment Utility
Hi ch2,

Thank You for Your help.

The $query part that is shown is the answer,
but the following code was generating errors previously:
if ($row['active']==1) {

$_SESSION['userid'] = $row['id'];
$_SESSION['access_level'] = $row['level'];
$_SESSION['logincode'] = genrandcode(40);

For some reason, the ONLY way that the script works is Without the single quotes as follows:
if ($row[active]==1) {

$_SESSION[userid] = $row[id];
$_SESSION[access_level] = $row[level];
$_SESSION[logincode] = genrandcode(40);

Thanks for Your input, though!

Have an Excellent Evening!

Respectfully,

FirstBorn
0
 
LVL 5

Expert Comment

by:dasmaer
Comment Utility
@ ch2: changing it may not have worked immediately, but it would open up it up to brand new errors.

Thanks for the grade.

D
0
 
LVL 1

Author Comment

by:FirstBorn
Comment Utility
Hi ch2,

Thanks for Your input.

"Changing only that won't work dasmaer. Well 4 minutes at the rubbish!"
"Why you accepted an answer without testing it before?"
Actually, I DID Test it and THAT was what was causing the error.

Once I added the Quote at the end, the page came up the way that it was Supposed to.

Thanks.

FirstBorn
0
 
LVL 11

Expert Comment

by:ch2
Comment Utility
If the way it works is producing a lot of notices good luck with your buggy app.

Mike
0
 
LVL 1

Author Comment

by:FirstBorn
Comment Utility
Hi Mike,

Thanks for Your comment.

k... I changed it over to the way that YOU showed it
(the way it WAS Originally with the single quotes) and
it works... (No Errors any more...)

Either way, it was the Quote at the end of the line that You
and dasmaer provided before that was causing all of the errors.

Respectfully,
Christopher
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now