Simple selection of two columns:
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT email, pasword FROM users");
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
This does not work
echo $result["email"];
Rest of the query
} catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
$conn = null;
When I echo $result["email"] it does not echo anything. I tried to echo the size of the $result array and it said it was a size of 1.