0

I'm new at PHP and I'm having trouble with an error in a project, I am trying to get data from mysql database, I used the same method for another page and it worked, I don't know why it isn't working, this is the error:

Notice: Undefined index: antari in C:\Users\Personal PC\Desktop\xamp\htdocs\phpushtrime\SMP PROJEKTI\SMP_ver4-perfundimi\inc\functions.php on line 65

Notice: Trying to access array offset on value of type null in C:\Users\Personal PC\Desktop\xamp\htdocs\phpushtrime\SMP PROJEKTI\SMP_ver4-perfundimi\inc\functions.php on line 65

Notice: Undefined index: antari in C:\Users\Personal PC\Desktop\xamp\htdocs\phpushtrime\SMP PROJEKTI\SMP_ver4-perfundimi\inc\functions.php on line 68

Notice: Trying to access array offset on value of type null in C:\Users\Personal PC\Desktop\xamp\htdocs\phpushtrime\SMP PROJEKTI\SMP_ver4-perfundimi\inc\functions.php on line 68

I've tried everything I know to fix it, but the same results.

here is an image of the function

here is an image of the code

THE CODE FOR THE PAGE:

<?php
        $punet = merrPunet();
        if ($punet) {
            while ($puna = mysqli_fetch_assoc($punet)) {
                $pid = $puna['punaid'];
                echo "<tr>";
                echo "<td>" . $puna['emri'] . "</td>";
                echo "<td>" . $puna['data'] . "</td>";
                echo "<td>" . $puna['pershkrimi'] . "</td>";
                echo "<td><a href='modifikopune.php?pid=$pid'>Edit</a></td>";
                echo "<td><a href='fshijpune.php?pid=$pid'>Delete</a></td>";
                echo "</tr>";
            }
        }
        ?>

THE FUNCTION I USED TO GET DATA FROM DATABASE:

function merrPunet() {
global $dbconn;
$antariid = ($_SESSION['antari']['antariid']);
$sql = "SELECT p.punaid,p.data,p.pershkrimi,pr.emri";
$sql .= " FROM punet p INNER JOIN projektet pr ON p.projektiid=pr.projektiid";
if ($_SESSION['antari']['roli'] == 0) {
    $sql .= " WHERE antariid=$antariid";
}
return mysqli_query($dbconn, $sql);

}

Thank You in Advance!

  • Presumably your Session value is empty. You need to debug your code to find out why that is. What you've shown doesn't give us any way to help you with that really. – ADyson Sep 15 '22 at 19:12

0 Answers0