vendredi 6 mars 2020

How can I collect result from prepare statement PHP?

I can't collect the results of my query in this function :

    require_once('connection.php');

    $idJoueur = session_id();

    if ($stmt = $conn->prepare('SELECT bestScore FROM Player WHERE ID = ?')) {
        $stmt->bind_param('i',$idJoueur);
        $stmt->execute();
        $result = $stmt->get_result();

        $data = $result->fetch_assoc();

        $bestScore = $data;

        if (!(empty($bestScore))) {
            header("Location: ../index.php");
        }

        return $bestScore;
    }
    else {
        $error = $conn->errno . ' ' . $conn->error;
        echo $error;
    }

}</code>

My connection works, I tried fetch_assoc(), store_result() but I failed every time




1 commentaire:

  1. According to Stanford Medical, It's in fact the one and ONLY reason women in this country live 10 years longer and weigh 42 pounds less than us.

    (By the way, it has totally NOTHING to do with genetics or some secret exercise and EVERYTHING about "HOW" they eat.)

    P.S, I said "HOW", not "WHAT"...

    CLICK this link to find out if this easy test can help you unlock your real weight loss potential

    RépondreSupprimer