I am writing again on a little import script which I have to split because of the data amount.

So I have a start.php with the fancy ajax action and the dbactions.php doing all the hard work.

The script first initializes the data, checks for doubles and creates a session with ids.

Then it should go through the ids in batches.

On first call the start.php has no errors, and the first part of the script runs well, in creates the user session with an array over 12k ids.

But when I output the result of the second initialize, it gives the the error message of

**Uncaught SyntaxError: Unexpected token }**

See screenshot attached:

![enter image description here](https://i.stack.imgur.com/YDlAU.jpg)

The dbactions.php itself gives no error despite the missing $do variable, and the start.php at first load also not.

The start.php looks like this:

```
<?php
header('Content-Type: text/html; charset=utf-8');
session_start();
$_SESSION['start_counter'] = 0;
$_SESSION['batches'] = 1;
$_SESSION['array_counter'] = 0;
$_SESSION['batchcount'] = 0;
$_SESSION['newsletter'] = 0;

?>

    <!DOCTYPE>
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <title>DB-actions</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="stylesheet" type="text/css" href="main.css" />
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
        <script>
            function DoSomething(what){
                var request = $.ajax({
                    url: "dbactions.php?do=" + what,
                    type: "GET",            
                    dataType: "html"
                });
                $('#godosomething').attr('disabled','true');
                $('#doing').show();
                $('#callmsg').empty();
                $('body').addClass('grey');
                request.done(function(msg) {
                    $('#doing').hide();
                    $("body").removeClass("grey");
                    $("#callmsg").html(msg);          
                });
                request.fail(function(jqXHR, textStatus) {
                    alert( "Request failed: " + textStatus );
                });
            }
        </script>
        <style type="text/css">
            padding, margin: 0;
            body  { padding:20px 0;}
            p { padding-bottom:3px;}
            #callmsg { margin:50px 0; }
            #insertmsg { margin:50px 0; }
            #doing { display:none; position:absolute; bottom:48%; right:48%; border: 1px solid green; padding: 20px; background-color:green; color: white;}
            .grey { background-color: grey; opacity: 0.5;}
            .green { color:green; }
        </style>
    </head>

    <body>

    <h1>Start the import</h1>
    <button type="button" onclick="DoSomething('initialize')" id="godosomething">Go baby</button>
    <div id="callmsg"></div>
    <div id="doing">I am working, please wait...</div>

    </body>
    </html>

```

I know there are several threads about it, the suggestions where, that the charset is wrong (not as excepted from ajax), but I have this on each file:

```
header('Content-Type: text/html; charset=utf-8');

```

And there was a suggestion about the ' and the " marks, I tried to change them in the output, but it did not help.

I thought also of the long output of the print\_r, but disabling it didn't help.

This is the second output:

```
echo '<h2>Batch successfull</h2>';
$_SESSION['start_counter'] = $_SESSION['start_counter'] + $numberofqueries;
$_SESSION['batches']++;
echo "<p>Next? <button type='button' onclick" . "='DoSomething('makearray')" ."id='godosomething'>Go baby</button></p>";
echo '<p>Batch'.$_SESSION['batches'].' from '.$_SESSION['batchcount'].'</p>';
echo '<pre>';
print_r($_SESSION['users']);
echo '</pre>';  

```

**ADDITIONAL EDIT**

I uncommented the whole second output until the h2 echo, and it still give me the same error.

How can this be? So the error comes not from the second output?