Hi,
when I run the following code, it works when I change the id value in the query string that is not in the database table, but it also says:
Notice: Undefined offset: 0 in C:xampphtdocssandboxorganising-pdoindex2.php on line 11
[code=php]require ‘functions.php’;
$conn = connect($config);
if ($conn) {
$id = isset($_GET[‘id’]) ? (int)$_GET[‘id’] : 11;
$row = get_by_id(“SELECT * FROM users WHERE id = :id”,
array(‘id’ => $id),
$conn)[0];
}
?>
<html>
<head>
<title></title>
</head>
<body>
<?php if ($row) : ?>
<h1><?= $row[‘username’];?>’s Profile </h1>
<?php else: ?>
<h1>No user</h1>
<?php endif; ?>
</body>
</html>
why? How can I fix it?