Parsing error - unexpected "=" on line 19

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Michael_C
Forum Commoner
Posts: 51
Joined: Thu Feb 09, 2006 4:32 pm
Location: California

Parsing error - unexpected "=" on line 19

Post by Michael_C »

I had an unusual error on a section of code that worked prior to yesterday, and noticed when I started to delve into the issue this morning the problem was gone. The change that was made yesterday morning was removing extra blank lines.

The error was on line 19 where the sql statement is being assigned to $q var.

Code: Select all

$dba = new ps_DB;
$q = "SELECT domain_host_id FROM domains WHERE 
			domain_account_id = '$account_id' AND 
			domain_host_status = '1'"; 
$dba->query($q);
The odd thing, even yesterday, the parsing error went away if I put back the blank lines:

Code: Select all

$dba = new ps_DB;

$q = "SELECT domain_host_id FROM domains WHERE 

			domain_account_id = '$account_id' AND 

			domain_host_status = '1'"; 

$dba->query($q);
This morning, I could run the script without the blank lines without error.
One thing I noticed on this website was excessive use of blank lines which made it difficult to read the script. I'm guessing whoever was originally doing the coding hit this problem and found putting in extra blank lines made it go away. I wrote a program to remove extra blank lines from the script and proceeded to test it - hence the error.

PHP version 4.4.1 is running on the server - Has anyone ran into this problem - Is it a server problem, or a schizophrenic php engine?

Michael
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

What server are you running? What OS? This seems a rather odd behavior for PHP.
Michael_C
Forum Commoner
Posts: 51
Joined: Thu Feb 09, 2006 4:32 pm
Location: California

Post by Michael_C »

Everah wrote:What server are you running? What OS? This seems a rather odd behavior for PHP.
Reported via phpinfo()
Linux waseda.lunarpages.com 2.4.21-27.0.4.ELsmp #1 SMP Sat Apr 16 18:43:06 EDT 2005 i686
Michael_C
Forum Commoner
Posts: 51
Joined: Thu Feb 09, 2006 4:32 pm
Location: California

Post by Michael_C »

I just received an email from the original developer, and he confirmed the reason he added the blank lines was to get around this parsing error.

He wrote "Yep, that code was often written with double and triple spacing. Like you have found, it works once, stops working, then works again."

Server problem? Php engine problem?

Michael
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Parse errors are the PHP engines way of telling you that there is something it is not liking with the script. Something to look at is how the files are being uploaded to the server (if this is a hosted server). Sometime if the files are sent as binary instead of ascii you'll get errors like this.

If it is not too big, maybe you can post the code and we can have a look.
Michael_C
Forum Commoner
Posts: 51
Joined: Thu Feb 09, 2006 4:32 pm
Location: California

Post by Michael_C »

Uploading was configured to send things as a binary file. I changed it to ascii - hopefully, I will remember to reset to binary when I go to upload executables. This morning I was prepared to look at the script for any non printable characters. But, I would have looked at my local copy, not the copy on the server. I'm pretty sure the script is ok, so will assume it's a ftp loading problem for now. I'll post the code if the problem comes back.

Thanks for the feedback - especially if this takes care of the problem :)

Michael
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Sounds like there are some hidden characters in the document. Try manually typing them out in a fresh new file (as in DO NOT copy and paste) -- OR -- opening the document in notepad which should show the hidden characters.

Things like this usual occur in software such as Dreamweaver (not sure if it was fixed in Dreamweaver 8, although I have no encountered this in a couple months)
Michael_C
Forum Commoner
Posts: 51
Joined: Thu Feb 09, 2006 4:32 pm
Location: California

Post by Michael_C »

Jcart wrote:Sounds like there are some hidden characters in the document. Try manually typing them out in a fresh new file (as in DO NOT copy and paste) -- OR -- opening the document in notepad which should show the hidden characters.

Things like this usual occur in software such as Dreamweaver (not sure if it was fixed in Dreamweaver 8, although I have no encountered this in a couple months)
I hadn't tried re-entering the script into a new file, but had re-typed it into the same file. Also moved it to the top of the file and the parsing error "moved" to new locatiion.
Whatever the issue is/was, it seems intermittent. The previous developer said the problem would come and go, until he added blank lines between each line of code. Then magically, the problem ceased to exist.

They did use Dreamweaver, and it is possible it is involved in this page's creation. The page is created via an "include" of a template html file - this file creates the buttons on the top and bottom of the page. The page content between the top and bottom buttons occurs by the following line in the template file:

Code: Select all

include("member_$page.html");
I'm checking into whether Dreamweaver was used in this area - Does Macromedia say they have a bug in this area? Sounds like you've seen the problem before - did it come and go, or was it repeatable? I haven't seen the problem since Sunday night, and I have run it at least a dozen times. I also wonder why the blank lines would prevent the problem from showing.

Michael
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

Try changing

Code: Select all

$q = "SELECT domain_host_id FROM domains WHERE

         domain_account_id = '$account_id' AND

         domain_host_status = '1'";
to

Code: Select all

$q = "SELECT domain_host_id FROM domains WHERE

         domain_account_id = '" . $account_id . "' AND

         domain_host_status = '1'";
Then check where account_id is coming from and whether its even filtered or escaped - if its not escaped it may need to be? Haven't a clue without knowing more about how the app works. Maybe try mysql_real_escape_string($account_id) in place of $account_id in my second code block, and remove the quotes around the '1' if this is hard coded.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

and remove the quotes around the '1' if this is hard coded.
integers don't need/shouldn't be quoted anyways..

Code: Select all

$sql = 'SELECT * FROM `table` WHERE `column` = '.intval($somevar);
or something along the lines is best, I find.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

Maybe Micheal could post the exact text of the error? It usually gives a few non-obvious clues as to exactly what's happening?
Michael_C
Forum Commoner
Posts: 51
Joined: Thu Feb 09, 2006 4:32 pm
Location: California

Post by Michael_C »

Maugrim_The_Reaper wrote:Maybe Micheal could post the exact text of the error? It usually gives a few non-obvious clues as to exactly what's happening?
Unfortunately, I didn't capture the error, and the problem hasn't repeated since Sunday night. I will post the exact wording if it ever re-appears.

Michael
Michael_C
Forum Commoner
Posts: 51
Joined: Thu Feb 09, 2006 4:32 pm
Location: California

Post by Michael_C »

Maugrim_The_Reaper wrote:Maybe Micheal could post the exact text of the error? It usually gives a few non-obvious clues as to exactly what's happening?
There was one additional thing I left out - this is not exact wording, but the gist.
the error said parsing error - unexpected "="

My main question was why it works some of the time, but not all of the time. Possibly I should have been asking a different question - e.g, was there a problem with the code? There are no specs for the website, so I'd have to dig in to figure the purpose of each field, etc. Essentially, I am adding an additional feature to the existing website. My goal was to locate a good place to "hook" my piece into the existing site. The code was so difficult to follow with the blank lines and other issues. I wrote a program that removed the blank lines. I saw the problem after uploading the file. I inserted blank lines before and after the line which had the reported error, and the problem ceased.
Sunday night I went through the excercise of adding blank lines to make the parse error go away, and then remove the lines to see the error re-appear. I wanted to see if I could make the problem repeat and did this multiple times(without any code changes.)
Monday I removed the blank lines, and the error did not re-appear.

There have been a number of good suggestions given, but it's tough to see if the change would resolve the problem when the problem isn't showing itself. I'll try them if the problem crops up again, but until then I'm still wondering why the intermittent behavior.

Michael
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

One possible cause of an intermittent problem is when specific "case"s are met/net met (if statement, switch statement, etc). Try posting the entire code or placing a text version of the script online somewhere where we can see it. Also, what is on line 18? Sometimes PHP reports problems with a line and the actual error is on the line just before it.

This is indeed an interesting problem. I would love to know the root cause of it when this is all resolved.
Michael_C
Forum Commoner
Posts: 51
Joined: Thu Feb 09, 2006 4:32 pm
Location: California

Post by Michael_C »

Everah wrote:One possible cause of an intermittent problem is when specific "case"s are met/net met (if statement, switch statement, etc). Try posting the entire code or placing a text version of the script online somewhere where we can see it. Also, what is on line 18? Sometimes PHP reports problems with a line and the actual error is on the line just before it.

This is indeed an interesting problem. I would love to know the root cause of it when this is all resolved.
There are ~320 lines in the file - I'll post the first 60 lines which could stand by itself.

Code: Select all

<?php	
echo('<body bgcolor="#FFFFFF"><p align="center"> ') ;	
$pass = is_logged($session_id);	
if ($pass == "N") {	
  include("member_login.html");	
} elseif($pass =="Y") 	
{	
  $larInfo = get_user_info(get_account_id($session_id),"",false, false) ;	
  echo("<b>Welcome " . $larInfo['acount_primary'] . " " . $larInfo['account_name'] . 	
    '! You are now logged into your account area. <a href="?page=account&next_page=account&session_id=' .	
     strval($session_id) . '&action=logout"><big>Log Me Out</big></a></b><br>') ;	
  $credits = credit_exsist($account_id);	
  if($credits > 0) 	
  {	
    echo("<BR><b>" . $larInfo['acount_primary'] .	
    ', you have an available account credit of ' . setup("currency") . number_format($credits,2) . "</b></p>");	
  }	
  $dba = new ps_DB;	
  $q = "SELECT domain_host_id FROM domains WHERE	
    domain_account_id = '$account_id' AND	
    domain_host_status = '1'";	
  $dba->query($q);	
  if ($dba->num_rows() > 0)	
  {	
    echo('<hr size="1" noshade><p><b>Please use your username and password on file to login to the area(s)	
         below that you have subscribed to.</b><br><br>') ; 	
    while ($dba->next_record())	
    {	
      $membership_id = $dba->f("domain_host_id");	
      $dbz = new ps_DB;	
      $q = "SELECT membership_name,membership_directory_id FROM membership WHERE membership_id = '$membership_id'"; 	
      $dbz->query($q);	
      $dbz->next_record();	
      $directory_id = $dbz->f("membership_directory_id");	
      if ($directory_id  != 0)	
      {	
        $dbd = new ps_DB;	
        $q = "SELECT directory_url FROM directory WHERE directory_id = '$directory_id'"; 	
        $dbd->query($q);	
        $dbd->next_record();	
        $directory_url = $dbd->f("directory_url");	
        echo('	
        <table width="100%" border="0" cellspacing="0" cellpadding="2" class="field_t"><tr> 	
          <td width="20%"><b>' . $dbz->p("membership_name") . '</b></td><td width="49%">	
            <a href="http://danceurdc.org/HTML/MEMBERS/Members2hidden.php"><big><big>	
            <font color="#0000FF" size="+1" face="Arial, Helvetica, sans-serif"><strong>CLICK 	
            HERE TO ENTER MEMBERS AREA</strong></font></big></big></a></td></tr>	
        </table></b>,<br><hr size="1" noshade>') ;	
      }	
    }	
  }	
  else	
  {	
    echo(	
     '<p>Your account does not have any active subscriptions at this point.<br>	
      If you have already placed an order, and it shows up below as pending, please 	
      be patient. We are processing your order and will complete it as soon as possible.<br></p>') ;	
  }
Post Reply