Solved

parse error, unexpected T_STRING

Posted on 2006-11-29
10
249 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

726 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