PHP Warning: Undefined array key "status"?

Hey,

Ich habe ein Array in PHP programmiert, welches per MySQL alle Sachen selektiert.

Nun werden aber die Arrays nicht gefunden.

Code:

$stmt = $link->prepare('SELECT * FROM tickets ORDER BY created DESC');
$stmt->execute();
$resultSet = $stmt->get_result();

// pull all results as an associative array
$tickets = $resultSet->fetch_all();

<?php foreach ($tickets as $ticket): ?>
  <a href="view.php?id=<?= $ticket['id'] ?>" class="ticket">
    <span class="con">
      <?php if ($ticket['status'] == 'open'): ?>
        <i class="far fa-clock fa-2x"></i>
      <?php elseif ($ticket['status'] == 'resolved'): ?>
        <i class="fas fa-check fa-2x"></i>
      <?php elseif ($ticket['status'] == 'closed'): ?>
        <i class="fas fa-times fa-2x"></i>
      <?php endif; ?>
    </span>
    <span class="con">
      <span class="title"><?= htmlspecialchars($ticket['title'], ENT_QUOTES) ?></span>
      <span class="msg"><?= htmlspecialchars($ticket['msg'], ENT_QUOTES) ?></span>
    </span>
    <span class="con created"><? date('F dS, G:ia', strtotime($ticket['created'])) ?></span>
  </a>

Fehler:

C:\xampp\htdocs\ticket.php on line 271
" class="ticket">
Warning: Undefined array key "status" in C:\xampp\htdocs\ticket.php on line 273

Warning: Undefined array key "status" in C:\xampp\htdocs\ticket.php on line 275

Warning: Undefined array key "status" in C:\xampp\htdocs\ticket.php on line 277

Warning: Undefined array key "title" in C:\xampp\htdocs\ticket.php on line 282

Warning: Undefined array key "msg" in C:\xampp\htdocs\ticket.php on line 283

Kann mir jemand sagen, ob ich etwas übersehen habe?

Computer, Webseite, programmieren, MySQL, PHP, Webentwicklung
wie könnte ich diesen Java Code kürzer/besser machen?

Hangman in Java

Wie könnte man so einen Code kürzer machen ?

public class hangiman {
    public static void main(String[] args) {
        System.out.println("Starting game");

        String notUsed = "abcdefghijklmnopqrstuvwxyz";

        String[] words = new String[]{"computer", "mouse", "screen", "display", "language"};

        String randomWord = words[(int) (Math.random() * words.length)];

        System.out.println("The word has " + randomWord.length() + " letters.");

        char[] letters = new char[randomWord.length()];

        Arrays.fill(letters, '.');
        int lives = 3;

        Scanner scanner = new Scanner(System.in);

        while (lives > 0) {
            System.out.print("Lives: ");

            for (int i = 0; i < lives; i++) {
                System.out.print("♥");
            }
            System.out.println();

            System.out.println("Input: ");

            String input = scanner.nextLine();

            char letter = input.charAt(0);


            boolean isGuessCorrect = false;
            for (int i = 0; i < randomWord.length(); i++) {
                char l = randomWord.charAt(i);

                if (l == letter) {
                    letters[i] = l;
                    isGuessCorrect = true;
                }
            }
            if (!isGuessCorrect) {
                lives = lives - 1;
            }
            boolean isGameFinished = true;

            System.out.print("Word: ");


            for (char c : letters) {
                if (c == '.') {
                    isGameFinished = false;
                }
                System.out.print(c);
            }
            System.out.println();

            notUsed = notUsed.replace(letter, '.');
            System.out.println("Not used " + notUsed);

            System.out.println("----------------------------------");

            if (isGameFinished) {
                System.out.println("You won!");
                break;
            }
        }
        if (lives == 0) {
            System.out.println("You lost! The word was: " + randomWord);
        }
        System.out.println("Exiting game");
    }
}

Computer, programmieren, Java, Informatik
Php Hashen mit "Salz" / PASSWORD_DEFAULT?
$password = "passwort";
$hashed = password_hash($password, PASSWORD_DEFAULT);
if(password_verify($password, $hashed)){
    echo $hashed;
}

Also so würde ich jetzt den string "passwort" hashen mit etwas vollkommen zufälligem / salz und es zb auf meiner datenbank speicher, alles schön und gut.

Jetzt kommt das große aber, wenn ich die Seite von irgendwo anders aufrufe. Dann mich einloggen will wird das eingegebene wieder gehasht mit einem salz um es mit der sql datenbank abzugleichen.

Das geht aber garnicht weil dieses Salz doch immer ein anderer ist wenn ihr versteht was ich meine.

Hashes ohne salz vergleichen kriege ich schonmal ohne probleme hin.

zum beispiel so würde mein login/abgleich mit der datenbank aussehen :

if(isset($_POST["username"]) && isset($_POST["password"])){

$hash = hash("sha512", $_POST["password"]);

$mysqli1 = new mysqli($servername, $user, $pw, $db);
$result = $mysqli1->query('SELECT id FROM user WHERE username = "'. $_POST["username"]. '"  ');
$result1 = $mysqli1->query('SELECT id FROM user WHERE password = "'. $hash. '"  ');

if($result->num_rows == 1 and $result1->num_rows == 1 ) {
  echo "Login erfolreich"; 
} else {
    echo "Falsches Passwort oder Nutzername";
}
$mysqli1->close();
}

Hab jetzt mysqli benutzt weil es irgendwie übersichtlicher ist, und ob das anfällig für Sql Injections oder so ist spielt eigentlich keine rolle erstmal. Manche stört das

PC, Server, Computer, Technik, Web, Webseite, programmieren, Passwort, Hash, Informatik, IT-Sicherheit, Kryptographie, MySQL, PHP, Programmiersprache, Technologie, web-development, Web Developer

Meistgelesene Beiträge zum Thema Computer