-1

I have been writing this code below with the help of everyone on here and about 3 php tutorials. When I run the code I am getting a syntax error for line 70(the second to last curly bracket}). It says that the bracket is unexpected, but I can't figie out why...

<?php

//defining function
function splitOne($V){

    //split array into smaller arrays
    array_chunk($data, 1);
    print_r($data);

    //map thumb part of array
    $thumb = array_map(str_getcsv($data[5], ";"));
    print_r($thumb);

    //map keyword part of array
    $keyword = array_map(str_getcsv($data[6], ";"));
    print_r($keyword);

    //remove last two fields of data
    array_pop($data);
    array_pop($data);

    //merge arrays 
    $v = array_merge($data, $thumb, $keyword);

    //return new array from function
    return $v;

}

//Connecting to database
$mysqli = new mysqli("localhost", "root", "password", 
"Studios");

//field Check
print_r("Connection Established");

//Scanning Directory
$dollar = glob("C:\Users\user\Desktop\CVS\XH\*.CSV");

//field Check
print_r("Data Collected" + $dollar);

foreach($dollar as $value) {
    while (($data = fgetcsv($dollar, 1002, "|")) !== FALSE){

        //remove first field
        $fruit = array_shift($data);
        print_r($data);

        //remove last string
        array_pop($data);
        print_r($data);

        //remove last string again
        array_pop($data);
        print_r($data);

        //remove last string a third time
        array_pop($data);
        print_r($data);

        //mapping array into function to manipulate
        array_map(splitOne, $data);


        $query = "INSERT INTO Quarantine (Url, 
EmbedUrl, Title, Duration, DateAdded, Thumb1, Thumb2, 
Thumb3, Thumb4, Thumb5, Thumb6, Thumb7, Thumb8, 
Thumb9, Thumb10, Keyword1, Keyword2, Keyword3, 
Keyword4, Keyword5, Keyword6, Keyword7, Keyword8, 
Keyword9, Keyword10) VALUES($V)";

        mysqli_query($conn, $query);
        //Field Check
        print_r("Data Entered Into Quarantine")
    }
}

?>

I am running a local wamp server on windows 7.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Database
  • 25
  • 4
  • 2
    You're missing a semicolon on the end of the line before it – Patrick Q Apr 15 '19 at 12:33
  • **Warning:** You are wide open to [SQL Injections](http://php.net/manual/en/security.database.sql-injection.php) and should really use parameterized **prepared statements** instead of manually building your queries. They are provided by [PDO](http://php.net/manual/en/pdo.prepared-statements.php) or by [MySQLi](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php). Never trust any kind of input, especially that which comes from the client side. Even when your queries are executed only by trusted users, [you are still in risk of corrupting your data](http://bobby-tables.com/). – Dharman Apr 15 '19 at 19:36

1 Answers1

-1
print_r("Data Entered Into Quarantine")

should be ==>

print_r("Data Entered Into Quarantine");

you are missing the semicolon as Patrick Q said

treyBake
  • 6,440
  • 6
  • 26
  • 57
Florent Cardot
  • 1,400
  • 1
  • 10
  • 19