Question: I was trying to connect to my local database through the php code but I get this error: 

> 
> Syntax error, unexpected '$result' (T\_VARIABLE), expecting ',' or ')'
> 
> 
> 

and I don't understand where's the problem. Here's my code:

```
    <?php
    $hostname = "localhost";
    $username = "root";
    $password = "";

    $databaseName = "newspage";

    $dbConnected = @mysqli_connect($hostname, $username, $password);

    $dbSelected = @mysqli_connect($databaseName, $dbConnected);

    $query = "INSERT INTO news(titolo, testo, data)VALUES('".$_POST["titolo"]."', '".$_POST["testo"]."', NOW())";
    $result = @mysqli_query($query);
    if(!$result){
    echo("Errore aggiunta news: " . mysqli_error(mysqli $result));
    exit();
    }

    else {
    mysqli_close(mysqli $dbConnected);
    echo('News caricata!<br><a href="add.php">Clicca qui</a> per aggiungere altre news.<br><a href="edit.php">Clicca qui</a> per apportare modifiche alle news.<br><a href="../index.php">Clicca qui</a> per tornare alla pagina principale.'); 
    }
?>

```

Answer: 
Your problem is in this line:

```
echo("Errore aggiunta news: " . mysqli_error(mysqli $result));

```

It should be:

```
echo("Errore aggiunta news: " . mysqli_error($result));

```
You should pass dbname too in `mysqli_connect`

```
$dbConnected = @mysqli_connect($hostname, $username, $password, $databaseName);

```

and to execute query. 

```
$result = $dbConnected->query("select * from tablename");

```

Further your query should be:

```
    $query = "INSERT INTO news(titolo, testo, data) 
    VALUES('".$_POST['titolo']."', '".$_POST['testo']."', NOW())";

```