Last active
March 26, 2018 16:48
-
-
Save arif98741/f4e0030c22a03203a9a2f5da0e0aa01d to your computer and use it in GitHub Desktop.
MySQLi Issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$con = new mysqli("localhost", "root", "password", "database"); | |
if($con) | |
{ | |
$username = "use124"; | |
$password = "pass123"; | |
$sql = "select * from userdata where username ='$username' and password = '$password'"; | |
$stmt = $con->query($sql); | |
if($stmt) | |
{ | |
if($stmt->num_rows>0) | |
{ | |
$value = $stmt->fetch_assoc(); | |
//$value = $stmt->fetch_object(); | |
echo "Hellow ".$value['name']; | |
//echo "Hellow ".$value->name; if you use fetch_object | |
//I usually use this type and pattern for coding | |
//regards www.phpdark.com | |
}else{ | |
echo "No Data Found"; | |
} | |
} | |
}else{ | |
echo "Failed To connect database" | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment