PHP error - Try_catch

Asked

Viewed 452 times

2

Parse error: syntax error, Unexpected 'catch' (T_CATCH), expecting end of file in C: xampp htdocs validar_cad_usuario face.php on line 65

My Project is here if anyone can help, I thank you!

    try {
                 // Returns a `Facebook\FacebookResponse` object
                $response = $fb->get('/me?fields=name, picture, email');
                $user = $response->getGraphUser();
                //var_dump($user);
                $result_usuario = "SELECT id, nome, email FROM usuario WHERE email='".$user['email']."' LIMIT 1";
                $resultado_usuario = mysqli_query($conn, $result_usuario);
                if($resultado_usuario){
                    $row_usuario = mysqli_fetch_assoc($resultado_usuario);
                        $_SESSION['id'] = $row_usuario['id'];
                        $_SESSION['nome'] = $row_usuario['nome'];
                        $_SESSION['email'] = $row_usuario['email'];
                        header("Location: administrativo.php");
                    }
                }               
            } catch(Facebook\Exceptions\FacebookResponseException $e) {
                echo 'Graph returned an error: ' . $e->getMessage();
                exit;
            } catch(Facebook\Exceptions\FacebookSDKException $e) {
                echo 'Facebook SDK returned an error: ' . $e->getMessage();
                exit;
            }
  • It’s a syntax error. No code, no way to tell where the problem is.

  • https://drive.google.com/file/d/10sL8xxdUv-cTkwmwyXmoSqLrawnDNcMa/view?usp=sharing

  • this is the project if you can take a look and help me

  • We didn’t miss a } of Try?

  • can you check, she’s there

  • 1

    managed to solve, the problem was the key of the if there above

Show 1 more comment

1 answer

1


probably forgot a dot and comma:

here is an example of Exceptions

<?php
function inverse($x) {
    if (!$x) {
        throw new Exception('Divisão por zero.');
    }
    return 1/$x;
}

try {
    echo inverse(5) . "\n";
    echo inverse(0) . "\n";
} catch (Exception $e) {
    echo 'Exceção capturada: ',  $e->getMessage(), "\n";
}

// Execução continua
echo "Olá mundo\n";
?>
  • can look there, but I checked several times and found no error

  • i went down and looked, the structure is not like that of my answer. for example at the beginning has a Try and 2 catchs

  • I know, but I got it right

Browser other questions tagged

You are not signed in. Login or sign up in order to post.