Solved

parse error, unexpected T_STRING

Posted on 2006-11-29
10
250 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
10 Comments
 
LVL 5

Accepted Solution

by:
dasmaer earned 500 total points
ID: 18042403
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
ID: 18042416
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
ID: 18042424
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
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 
LVL 11

Expert Comment

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

Thanks.

0
 
LVL 11

Expert Comment

by:ch2
ID: 18042440
Why you accepted an answer without testing it before?
0
 
LVL 1

Author Comment

by:FirstBorn
ID: 18042443
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
ID: 18042448
@ 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
ID: 18042459
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
ID: 18042460
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
ID: 18042480
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

688 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