0

This is my first php page and I cant find the error.

Please help me.

Error:

PHP Parse error: syntax error, unexpected 'echo' (T_ECHO) in /var/www/html/login.php on line 17

Code:

<?php
    $servername = "localhost";
    $username = "sao";
    $passwort = "12345";
    $dbName = "sao";
    $user_username = $_POST["usernamePost"];
    $user_password = $_POST["passwordPost"];
    $conn = new mysqli($servername, $username, $passwort, $dbName);
    if(!$conn){
        die("Connection Failed. ". mysqli_connect_error()); 
    }
    $sql = "SELECT password FROM users WHERE username = '".$user_username."' ";
    $result = mysqli_query($conn ,$sql);
    if(mysqli_num_rows($result) > 0){
        while($row = mysqli_fetch_assoc($result)){  
            if($row['password'] == $user_password{          
                echo "login erfolgreich";
            }else{  
                echo "password falsch"; 
            }
        }
    }else{
        echo "user nicht gefunden";
    }
?>

Thank you for helping me.

Sorry for my bad english!

BeDa
  • 1
  • 1
  • 2
    `if($row['password'] == $user_password{ ` Get a good IDE/Editor with syntax checking. It will save you a lot of headaches. – aynber Mar 14 '18 at 14:59
  • Which IDE/Editor do you recommend to me? – BeDa Mar 14 '18 at 15:05
  • I personally use PHPStorm, but there's also Notepad++, and I think Eclipse. – aynber Mar 14 '18 at 15:16
  • I used Notepad++ but there find no error :C – BeDa Mar 14 '18 at 15:18
  • 1
    + for PHPStorm. It's not cheap but it is worth it. Not recommending this as an IDE but I use Sandbox on SO often which catches many syntax errors - http://sandbox.onlinephpfunctions.com/code/edf2ef69069969f22e5f2824f1b02a3feca14b0d – waterloomatt Mar 14 '18 at 15:27
  • @aynber, Why are you not answering the question? I think this question can't be closed since its not offtopic. **Sorry missed a word. – learner Mar 14 '18 at 15:32
  • Thanks you for trying to help me but i don´t understand why there are a error on this echo :C – BeDa Mar 14 '18 at 15:33
  • Because you have a syntax error / typo on the line pointed out in the first comment – Patrick Q Mar 14 '18 at 15:34
  • Lol. you need to close the bracket BeDa. Instead of `if($row['password'] == $user_password` close with ')' bracket like `if($row['password'] == $user_password)`. @PatrickQ I think its not about comment. Its the problem with not having closing bracket. – learner Mar 14 '18 at 15:34
  • Ohh now i see it. Thanks a lot! – BeDa Mar 14 '18 at 15:37

0 Answers0