[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

parse error, unexpected T_STRING

Posted on 2006-11-29
10
Medium Priority
?
255 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 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
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.

 
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
This article discusses how to implement server side field validation and display customized error messages to the client.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…
Suggested Courses

656 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