?
Solved

parse error, unexpected T_STRING

Posted on 2006-11-29
10
Medium Priority
?
258 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 2000 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month14 days, 11 hours left to enroll

839 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