Hey, im making a upload page, but i am getting this error:

Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\config.php on line 37

This is line 36 and 37:

// include language file
include_once("language/".$site_config['SITE_LANG'].".php");

Can anyone help me?

    legrand;10883548 wrote:

    Hey, im making a upload page, but i am getting this error:

    Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\config.php on line 37

    This is line 36 and 37:

    Can anyone help me?

    try:

    include_once("language/".$site_config['SITE_LANG'] . ".php");
    

      That's just the same line with some extra spaces!

      Try:

      include_once("language/{$site_config['SITE_LANG']}.php");
      

      If this still gives you errors, then just check to see what exactly is in the $site_config['SITE_LANG'] variable.

        Ashley Sheridan;10883553 wrote:

        That's just the same line with some extra spaces!

        Try:

        include_once("language/{$site_config['SITE_LANG']}.php");
        

        If this still gives you errors, then just check to see what exactly is in the $site_config['SITE_LANG'] variable.

        HAHA oh man cant believe i didint see that! My bad.

          Hmm, still didnt work.. i will try to check the variable, thank you btw.

            If anyone has any ideas please come with them..🙂

              Have you tried outputting the URL that your code is trying to find like this:

              print "language/{$site_config['SITE_LANG']}.php";
              

              And is this URL fully accessible from your relative location. You might need to check if permissions are set to allow read access to Apache (or whatever web server you are using)

                This is text near the 37 line:

                //FULL PATH to the "smarty" folder. Path should END WITH a slash.
                //If you are not sure what the setting is, point your browser to the
                //"path.php" file in the smarty folder. That is, point to:
                //http://yourdomain.com/filestore/smarty/path.php
                define("SMARTYPATH", "C:\xampp\htdocs\smarty\");

                // include language file
                include_once("language/".$site_config['SITE_LANG'].".php");

                //Maximum filesize allowed for file upload. Specify value in BYTES.
                $upload_config=array(
                "max_size"=>"5242880", // 1Kb = 1024 ; 1Mb = 1048576 ; 5Mb = 5242880

                // File extensions allowed
                "ext"=>array("jpg", "gif", "png", "txt", "pdf", "htm", "html", "doc", "xls")
                );

                Any problems there?

                  Yes. Look carefully at:

                  define("SMARTYPATH", "C:\xampp\htdocs\smarty\");

                  The closing double quote was escaped by the backslash before it. Also, because you are using double quote delimited strings, you should take care to escape the other backslashes as well. For example, the syntax highlighting reveals that \xa could well be taken as a character specified in hexadecimal.

                  Your original line was fine:

                  include_once("language/".$site_config['SITE_LANG'].".php");

                  The error was detected on the above line, but the error was before it.

                    I tried to change the path of smarty to C:\smarty\ and configure the config.php to

                    define("SMARTYPATH", "C:\xampp\htdocs\smarty\");

                    But still the same error, was that wrong?

                      As I said, escape the backslashes:

                      define("SMARTYPATH", "C:\\xampp\\htdocs\\smarty\\");

                        Oh yeah, sorry, it worked.. but now i got a new error:

                        Warning: Unexpected character in input: '\' (ASCII=92) state=1 in C:\xampp\htdocs\filestore\config.php on line 41

                        Warning: require_once(C:/xampp/htdocs/filestore/smartySmarty.class.php) [function.require-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\filestore\libs\header.php on line 17

                        Fatal error: require_once() [function.require]: Failed opening required 'C:/xampp/htdocs/filestore/smartySmarty.class.php' (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\filestore\libs\header.php on line 17

                        Do you know what this is?

                          Probably the same problem: you are not escaping backslashes when you need to. Generally, you can avoid most of these backslash escaping by using single quote delimited strings (in which case you only need to escape a backslash if it is at the end of the string literal, or would otherwise cause an unintended escaping). Read the PHP manual on strings for more information.

                            Your problem is because you are using forward slashes and Windows expects backwards slashes:

                            so: C:/xampp/htdocs/filestore/smartySmarty.class.php should become: C:\xampp\htdocs\filestore\smartySmarty.class.php (note that if you have this enclosed in double quotation marks then each backlslash needs to be a double backslash.

                            Repeat for the line indicated by the second error message.

                              Your problem is because you are using forward slashes and Windows expects backwards slashes:

                              I have my doubts since require_once should be able to translate 'C:/xampp/htdocs/filestore/smartySmarty.class.php' correctly.

                                Oh, thank you, it worked! Now i can enter the site but it still says at the top:

                                Warning: Unexpected character in input: '\' (ASCII=92) state=1 in C:\xampp\htdocs\filestore\config.php on line 41

                                One of these is line 41

                                //Maximum filesize allowed for file upload. Specify value in BYTES.
                                $upload_config=array(
                                "max_size"=>"5242880", // 1Kb = 1024 ; 1Mb = 1048576 ; 5Mb = 5242880

                                I believe it is the last problem

                                  So is require_once() converting them to backslashes, which are themselves not escaped? Would probably be best to just use double backslashes for peace of mind?

                                    Ok, i got it working, Thank You very much everyone!

                                      Ok, i got it working, Thank You very much everyone!

                                      No problem 🙂
                                      Remember to mark this thread as resolved using the thread tools.

                                      Also, kindly tell us how you solved your problem (e.g., show the code that was wrong, and then what you did to correct it). This could help another person who has a similiar problem and found this thread.

                                      EDIT:

                                      Ashley Sheridan wrote:

                                      So is require_once() converting them to backslashes, which are themselves not escaped?

                                      No, since that would be incorrect translation. I'm fairly sure that part of legrand's code used paths with backslashes, and these needed the escaping, but the other part that used paths with forward slashes were fine.

                                      Ashley Sheridan wrote:

                                      Would probably be best to just use double backslashes for peace of mind?

                                      Considering that this is a Windows specific absolute path, I'd say yes, just so as to avoid surprising people (you are a good example :p). On the other hand, if it were relative to $_SERVER['DOCUMENT_ROOT'], using forward slashes would be the better option since that would likely be how the path would be formatted, even on Windows.

                                        Write a Reply...