0

I'm running in errors in my PHP script, I used to have my server on cPanel but switched over to Plesk. While on cPanel I had no issues but on Plesk I keep running into issues.

We are currently running PHP 5.6

Error:

Parse error: syntax error, unexpected ']', expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\Inetpub\vhosts\retroleads.com\httpdocs\wp\data.php on line 8

Source:

<?php
$iterator = new FilesystemIterator("C:\Inetpub\vhosts\retroleads.com\wp\");
$filter = new RegexIterator($iterator, '/.(csv)$/');
$filelist = array();


foreach($filter as $entry) {
    $filelist[] = $entry->getFilename();
}

foreach($filelist as $filelist){

    $open = fopen($filelist, "r") or die("Unable to open file!");
    //Loop through the CSV rows.
    while (($row = fgetcsv($open, 0, ",")) !== FALSE) {
    //Dump out the row for the sake of clarity.
    //var_dump($row);

        //run cURL for postback

        // create curl resource 
        $ch = curl_init(); 

        //check for underscores
        if (preg_match('/_/', $row[3])) {

            //explode the string
            $row[3] = explode("_", $row[3]);
            $row[3] = $row[3][1];

        }else{

            $row[3] == $row[3];

        }

        // set url 
        curl_setopt($ch, CURLOPT_URL, "http://tracking.retroleads.com/advBack.php?click_id={$row[3]}"); 

        //return the transfer as a string 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

        // $output contains the output string 
        $output = curl_exec($ch); 

        // close curl resource to free up system resources 
        curl_close($ch);
    }
}
?>
M. Eriksson
  • 13,450
  • 4
  • 29
  • 40
  • You need to use double backslashes. Change: `"C:\Inetpub\vhosts\retroleads.com\wp\"` to `"C:\\Inetpub\\vhosts\\retroleads.com\\wp\\"`. Backslash is an escape character if you have them inside double quoted strings. If your string ends with a backslash, it escapes the closing `"`, which results in you not actually closing the string. You can see it on the syntax highlighting. – M. Eriksson Feb 02 '18 at 14:15
  • Or use single quotes around the path, like `'C:\Inetpub\vhosts\retroleads.com\wp\'` – dkasipovic Feb 02 '18 at 14:18
  • The syntax highlighting kinda makes it obvious where the error lies – John Conde Feb 02 '18 at 14:27

0 Answers0