Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Trying to make if statement with php

Hello i am trying to make a simple if else php statement this is my code but isnt working

$sql = "SELECT UserType from user where Username = '$email'";
        
            $result = mysqli_query($connection, $sql);
            if($sql == 'A'){
                echo 'Passed';
            }else{
                echo 'Error';
            }
            ?>

i also tried changin the if($sql == 'A') to if($result == 'A') but still nothing. Am i missing something?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

This might help:

$sql = "SELECT UserType from user where Username = '$email'";      

if($result = mysqli_query($connection, $sql)){
    $row = mysqli_fetch_array($result, MYSQLI_ASSOC);
    if($row['UserType'] == 'A') {
        echo 'Passed';
    }
    else {
        echo 'Error';
    }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading