Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hi!

Please help me to solve this error:
Parse error: syntax error, unexpected '{'


What's wrong with my code:

<?php
    $sql = "SELECT * FROM tbl_user WHERE username = ?";
    $stmt = $db->prepare($sql);
    $result = $stmt->execute([$_POST['username']]);
    $un = $result->fetchAll();
        if (isset($un[0]) {
        if (password_verify($_POST['password'], $un[0]->password) {
            echo "login success";
          } else {
            echo "wrong password";
          }
        } 
?>


Looking forward for your quick response. Thank you in advanced

What I have tried:

A lot of manipulation to my code.
Posted
Updated 5-Sep-18 2:05am
Comments
ZurdoDev 4-Sep-18 13:43pm    
0. Figure out what line of code is causing the error.
1. Figure out why some variable has bad syntax.
Kenjiro Aikawa 4-Sep-18 15:08pm    
This line causing the error:

if (isset($un[0]) {
ZurdoDev 4-Sep-18 15:48pm    
Because you are missing closing parentheses.
Kenjiro Aikawa 4-Sep-18 21:06pm    
Thank you but I got new error after add closing.

Parse error: syntax error, unexpected 'echo' (T_ECHO)

1 solution

Parser errors means you have typed something wrong. In the first case you were missing closing parentheses. Now you are getting another error and it's for the same reason.

Please take the time to review your code carefully and pay attention to what the compiler is telling you. It is specifically telling you that you typed something wrong on a certain line.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900