Skip to content

Instantly share code, notes, and snippets.

@arif98741
Last active March 26, 2018 16:48
Show Gist options
  • Save arif98741/f4e0030c22a03203a9a2f5da0e0aa01d to your computer and use it in GitHub Desktop.
Save arif98741/f4e0030c22a03203a9a2f5da0e0aa01d to your computer and use it in GitHub Desktop.
MySQLi Issue
<?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