#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    10
    Rep Power
    0

    Parse error: syntax error? help?


    Hey all, i ran into some troubles with my script.
    It puts out this error:
    Parse error: syntax error, unexpected '[' in Init.php on line 15

    Init.php:
    PHP Code:
    <?php
    define
    ('IP'str_replace('::1''127.0.0.1'$_SERVER['REMOTE_ADDR']));

    ini_set('default_charset''UTF-8');
    ini_set('expose_php'0);
    ini_set('session.name''DO-BPP1');
    ini_set('session.gc_probability'10);
    ini_set('session.gc_divisor'100);
    ini_set('session.cookie_httponly'1);
    ini_set('session.gc_maxlifetime'600);
    ini_set('zlib_output_compression''On');

    $_SERVER['REQUEST_URI'] = str_replace('.php'''strtolower($_SERVER['REQUEST_URI']));
    if(
    strstr($_SERVER['REQUEST_URI'], '?')):
        
    define ('URI'explode('?'$_SERVER['REQUEST_URI'])[0]);
    else:
        
    define ('URI'$_SERVER['REQUEST_URI']);
    endif;

    @
    session_start();

    require(
    "./Server.Config.php");

    if(!empty(
    $_SERVER['SERVER_NAME'])):
        
    $_Server str_replace("www."""$_SERVER['SERVER_NAME']);

        if(!empty(
    $Config['URL']["tv2sever"]) && ($Config['URL']["tv2sever"] === $_SERVER['SERVER_NAME'])):
            
    $Config['Lang'] = $Config['URL']['Default']['Lang'];
            
    define("SERVER""http://" $_SERVER['SERVER_NAME']);
            
    define("HOST"$_SERVER['SERVER_NAME']);
            
    define("sSERVER""http://" $_SERVER['SERVER_NAME']);
        elseif(isset(
    $Config['URL']['Other'][$_Server])):
            
    $Config['MySQL'] = $Config['URL']['Other'][$_Server]['MySQL'];
            
    $Config['Lang'] = $Config['URL']['Other'][$_Server]['Lang'];
            
    define("SERVER", ($Config['URL']['Other'][$_Server]["Require.www"]) ? "http://www." $_Server "http://" $_Server);
            
    define("HOST", ($Config['URL']['Other'][$_Server]["Require.www"]) ? "www." $_Server $_Server);
            
    define("sSERVER", ($Config['URL']['Other'][$_Server]["SSL.enabled"]) ? "https://" HOST "http://" HOST);
        elseif(!empty(
    $Config['URL']["Default"]["Server"])):
            
    $Config['Lang'] = $Config['URL']['Default']['Lang'];
            
    define("SERVER", ($Config["URL"]["Default"]["Require.www"]) ? "http://www." $Config['URL']["Default"]["Server"] : "http://" $Config['URL']["Default"]["Server"]);
            
    define("HOST", ($Config["URL"]["Default"]["Require.www"]) ? "www." $Config['URL']["Default"]["Server"] : $Config['URL']["Default"]["Server"]);
            
    define("sSERVER", ($Config["URL"]["Default"]["SSL.enabled"]) ? "https://" HOST "http://" HOST);
        else:
            echo 
    "You don�t have access.";
            exit;
        endif;
    else:
        exit;
    endif;

    $MySQLi = new mysqli($Config['MySQL']["host"], $Config['MySQL']["user"], $Config['MySQL']["pass"], $Config['MySQL']["dbname"]);

    if (
    $MySQLi->connect_error) {
        die(
    'Error de Conexi�n MySQLi (' $MySQLi->connect_errno ') '
                
    $mysqli->connect_error);
    }

    $_mysqliCharacter $MySQLi->character_set_name();

    require 
    'Class.Core.php';
    $Core = new Core();


    $_POST str_replace(['<''>''\'''\'''\\'], ['&lt;''&gt;''&quot;'''', '\'], $_POST);
    $_GET = str_replace(['
    <', '>', '\'''\'''\\'], ['&lt;''&gt;''&quot;'''', '\'], $_GET);

    DEFINE('
    FILES', 'Files/' . DIRECTORY_SEPARATOR . $Config['Lang'] . DIRECTORY_SEPARATOR);
    DEFINE('
    GLOBALS', FILES . '/GLOBAL/');
    ?>
    And it gives me same errors with [
    in this script:

    PHP Code:
    <?php
    $Config
    ['URL'] = [
        
    'Default' => [
            
    'Require.www' => false
            
    'SSL.enabled' => false
            
    'Server' => 'localhost',
            
    'Lang' => 'da' // GLOBAL.
        
    ],
        
    'Other' => [
            ],
        
    'tv2sever' => 'localhost' 
    ];

    $Config['MySQL'] = [
        
    'host' => 'localhost',
        
    'user' => '*',
        
    'pass' => '**',
        
    'dbname' => '***'
    ];
    ?>
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,990
    Rep Power
    375
    $_POST = str_replace(['<', '>', '\'', '\'', '\\'], ['<', '>', '"', ''', '\'], $_POST);
    $_GET = str_replace(['<', '>', '\'', '\'', '\\'], ['<', '>', '"', ''', '\'], $_GET);

    is the problem..

    you wanna create two arrays

    $find = array ("<",">",.....);
    $replace = array ("<",">",....);

    then str_repalce($fine, $replace, $_POST);

    also i am not sure what you are trying to do but you are replacing < with < ? which doesnt make sense.

    FInally, when you pasted the code, if you looked at your post/code you would have seen forum devshed's php functionality telling you exactly where the problem is.

    You need a good IDE that can give you this info. The one I use is Komode Edit, install that and php.exe and you will be told of these errors while you are writing your scripts
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    10
    Rep Power
    0
    Originally Posted by paulh1983
    $_POST = str_replace(['<', '>', '\'', '\'', '\\'], ['<', '>', '"', ''', '\'], $_POST);
    $_GET = str_replace(['<', '>', '\'', '\'', '\\'], ['<', '>', '"', ''', '\'], $_GET);

    is the problem..

    you wanna create two arrays

    $find = array ("<",">",.....);
    $replace = array ("<",">",....);

    then str_repalce($fine, $replace, $_POST);

    also i am not sure what you are trying to do but you are replacing < with < ? which doesnt make sense.

    FInally, when you pasted the code, if you looked at your post/code you would have seen forum devshed's php functionality telling you exactly where the problem is.

    You need a good IDE that can give you this info. The one I use is Komode Edit, install that and php.exe and you will be told of these errors while you are writing your scripts
    Thank you for the answer, but i got the problem fixed

    Anyways, have a good day sir.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,990
    Rep Power
    375
    next time, please close the thread (or update your post) so people dont waste their time!
  8. #5
  9. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Please do not close your thread. Often times, other users have additional remarks (especially with regard to security and best practices), so don't close the thread just because one particular problem has been solved. There may be others you don't even know yet.

    Also, when you've solved the problem yourself, then post the solution. Many people (including myself) search the Internet if they have a problem, and there's nothing more frustrating than to see a thread about the same problem end with "I solved it. Bye.". That's not helpful.

    In this case, I guess your PHP version simply doesn't support the new array syntax ([...]) yet?
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    10
    Rep Power
    0
    Originally Posted by Jacques1
    In this case, I guess your PHP version simply doesn't support the new array syntax ([...]) yet?
    currectly, i did on my localhost, but when i uploaded it to my site.

    It messed up

    My host is going to here from me now :9
  12. #7
  13. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    Your host has no obligation to upgrade PHP, you pay for a specific version and that's what you get. Upgrading the host will likely break existing code. Your next-generation code not working on a last-generation host isn't really their problem.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  14. #8
  15. No Profile Picture
    Dazed&Confused
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2002
    Location
    Tempe, AZ
    Posts
    506
    Rep Power
    128
    Originally Posted by ManiacDan
    Your host has no obligation to upgrade PHP, you pay for a specific version and that's what you get. Upgrading the host will likely break existing code. Your next-generation code not working on a last-generation host isn't really their problem.
    It's their problem when customers begin to leave for providers that keep their servers updated properly, like I would if I were in Xkay's position and the provider didn't offer a solution.

IMN logo majestic logo threadwatch logo seochat tools logo