0

SQL statement works perfectly on db, param value evaluates correctly. Connection works (there's a previous db request that has successfully closed), but bind_param fails.

        $sql3 = "SELECT s.teacher AS teacher,
                rL.classTotal
            FROM students AS s
            LEFT JOIN
                (SELECT SUM(rL.minutes) as classTotal,
                rL.stSponsorId as stSponsorId
                FROM readingLog rL
                GROUP BY rL.stSponsorId) rL
            ON rL.stSponsorId = s.stSponsorId
            WHERE teacher = ?
            GROUP BY s.teacher";
    $param_teacher = $user_arr[$j]['teacher'];
    echo "<p> param_teacher: ".$param_teacher."</p>";
    $stmt3 = mysqli_prepare($link, $sql3);
    if(!mysqli_stmt_bind_param($stmt3, 's', $param_teacher)){
        echo "<p>failed to TEACHER bind param</p>";
    } else {
        if(!mysqli_stmt_execute($stmt3)){
            echo "<p>failed to execute teacher.</p>";
            printf("Error: %s.\n", mysqli_stmt_error($stmt3));
        }
        if(!$result3 = mysqli_stmt_get_result($stmt3)){
            print "<p>teacher results did not load.</p>";
        }
    }
Dharman
  • 30,962
  • 25
  • 85
  • 135
Enedc
  • 3
  • 2

0 Answers0