• PHP Help Upgrading PHP
  • [RESOLVED] FATAL ERROR syntax error, unexpected '""' (T_CONSTANT_ENCAPSED_STRING) Line 104

Please bare with me... I am by no means a coder and this is very new to me but I am trying to learn as I go. I am currently trying to learn by modifying a script I have that is written with php 5.2. My intent is to bring it up to php 5.6 by learning to write php. I realize this is going to be a long journey for me... so please bare with me, I'll need all the help and information I can gather along the way.

In doing this rewrite, I am running my current script in a test module set for php 5.6 and correcting each line as I go... I guess that is the only real way I can do this without knowing the complete php code.

This is an error I have come across. I see what it is stating but I don't want to make an assumption about what I am changing to correct this error.

FATAL ERROR syntax error, unexpected '""' (T_CONSTANT_ENCAPSED_STRING) on line number 104

My script lines 101 - 107

101 $domain = ".".$_SERVER['HTTP_HOST'];
102 }
103 $license = false;
104 if ( file_exists( dirname( """"""__FILE__ not allowed" not allowed" not allowed" not allowed" not allowed" not allowed" )."/..//license" ) && lic( $domain ) == file_get_contents( dirname( """"""__FILE__ not allowed" not allowed" not allowed" not allowed" not allowed" not allowed" )."/..//license" ) )
105 {
106    $license = true;
107 }

Please correct me if I am wrong.... from what I see according the the error report there is an issue with the quotes """""" being used. What I am not quite understanding is why?... It is the way they are being used in the statement? If it is how they are being used, what is the correct way to use this in this instance?

Again... my apologies for being extremely new to php and coding, but I need to start somewhere and the beginning is usually the best place.

Thank you all for your help in my quest to learn and get this project working again on a 5.6 level.

    DT2000 wrote:

    Please bare with me...

    I don't know you well enough to do that.

    Please correct me if I am wrong.... from what I see according the the error report there is an issue with the quotes """""" being used. What I am not quite understanding is why?... It is the way they are being used in the statement? If it is how they are being used, what is the correct way to use this in this instance?

    That is what the error refers to. The question you need to answer is: what do you think the code is supposed to do?
    [font=monospace]""""""[/font] meaningless in PHP, and probably an artefact of nesting [font=monospace]"... not allowed"[/font] half a dozen times. Why that is there at all is another question, because it shouldn't be (you're probably supposed to have [font=monospace[dirname(FILE)[/font].

      Ok, I briefly read a little something on "nesting" a week ago and that it is not allowed now. This is from a script written with 5.2... so that may explain why it was done that way, I'm not sure to be honest.

      I will see what happens redoing the line in the method you have suggested and see what happens.

      I appreciate the help.

        So, to really answer your question, you probably need to explain to us what all those "not allowed" things in your code are supposed to be, and what that piece of code is actually trying to do with them. I could get rid of the syntax errors by various uses of escaping quotes with the "\" character, using the "." concatenation operator, and so forth; but I have no idea what the correct implementation would be at this point -- although my guess would be this is all you really want:

        $file = dirname(__FILE__)."/..//license";
        if(file_exists($file) && lic($domain) == file_get_contents($file)) {
        

          PS dirname(FILE) is the same thing as DIR

            I am using "phped" to go through the script to try to make this thing compliant to php 5.6 (which seems to be working)... but is there another or better debugger that will find the errors in the scripts compatibility between php 5.2 and php 5.6?

            I have made the corrections to the prior string and it passes, so I am thankful for the suggestions and help.

            "Derokorian" in your comment you say that "FILE" is the same as using "DIR", does this mean either can be used as the statement and will result in the same processing of the code?

            Such as:

            $file = dirname(__DIR__)."/..//license";
            if(file_exists($file) && lic($domain) == file_get_contents($file)) {  

            I'm just beginning so every bit of information about how and why something in the change is needed helps me learn the correct ways to write PHP.

              DT2000;11052541 wrote:

              "Derokorian" in your comment you say that "FILE" is the same as using "DIR", does this mean either can be used as the statement and will result in the same processing of the code?

              Such as:

              $file = dirname(__DIR__)."/..//license";
              if(file_exists($file) && lic($domain) == file_get_contents($file)) {  

              No, in fact I said:

              Derokorian;11052539 wrote:

              PS dirname(FILE) is the same thing as DIR

              So to your example, it would be:

              $file = __DIR__."/..//license";
              if(file_exists($file) && lic($domain) == file_get_contents($file)) {  

              Edit: See here for more info - http://php.net/manual/en/language.constants.predefined.php

                ok... I had also thought about it being written in that style string as well... but needed to be clear.

                Thank you for clarifying it, it's appreciated.

                  Write a Reply...