Getting an unexpected error don't know what the hell is wrong as everything is perfect as far as I noticed

Parse error: syntax error, unexpected '=' in C:\wamp\www\dropbox-sdk\index.php on line 18


<?php
    session_start();

    require_once "lib/Dropbox/autoload.php";

    $_SESSION["user_id"] = 1;

    $dropboxKey     = '';
    $dropboxSecret  = '';
    $appName        = 'puttiapp/1.0';

    $appInfo = new Dropbox\AppInfo($dropboxKey, $dropboxSecret);

    $csrfTokenStore = new Dropbox\ArrayEntryStore($_SESSION, 'droppbox-ayth-csrf-token');

    $webauth = new Dropbox\WebAuth($appInfo, $appName, 'http://localhost/editmate/dropbox_finish.php', $csrfTokenStore);

    $database = new PDO(mysql::host=localhost;dbname=editmate;dbuser=root);
    $user   = $database->prepare("SELECT * FROM users WHERE id = :user_id");
    $user->execute(['user_id' => $_SESSION['user_id']]);
    $user = $user->fetchObject();

    var_dump($user);
?> 

Why do you need a backslash in new Dropbox\AppInfo(...) and in 2 other places???

Also, I am not sure you are creating PDO correctly. Shouldn't it be something like...

$database = new PDO('mysql::host=localhost;dbname=editmate;dbuser=root');
commented: “Dropbox” in this case could be a namespace that is referenced directly or through a use statement. +9
Member Avatar for diafol

Try:

$database = new PDO("mysql:host=localhost;dbname=editmate","root","");

Sounds like the root of your error problem (root, get it? he heh, never mind).

commented: ;) . Yes this was line 18 (before adding the comments to code to make it trickier). The root of the problem is to read the error message ;) +9
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.