2018-03-22 17:47

是什么导致了这个错误? mysqli_stmt :: bind_result():


I'm using mysqli_prepare() so the thing is I get this error always.

Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement in download.php on line 12

Fatal error: Uncaught exception 'mysqli_sql_exception' with message 'No data supplied for parameters in prepared statement' in ***gg.php:13 Stack trace: #0 \download.php(13): mysqli_stmt->execute() #1

include('.') #2 {main} thrown in

download.php on line 13

I looked up in other questions but I didn't manage to get the solution.

my code :


$cert_id = $_GET['cert_id'];
$stmt1 = mysqli_prepare($connection,"SELECT cert_id,certificate_id,name_student,hours_com,course_title FROM cert JOIN courses WHERE cert_id = ? AND course_id = certificate_id");
  $pdf = new \setasign\Fpdi\Fpdi();
  $pagecount = $pdf->setSourceFile('cert.pdf');
  $tplIdx = $pdf->importPage(1);
  $pdf->SetFont('times', 'B', 35);
  $pdf->cell(20, 10,$name_student,  'C');
  $pdf->SetFont('times', 'B', 35);
  $pdf->cell(90, 100, $course_title, 'C');
  $pdf->cell(40, 10, $hours_com 'C');



line 12 & 13 :


Any idea what is wrong here?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dpw63348 dpw63348 3年前

    The question marks in your query are placeholders for values that you'll add later. The number of them needs to match the number of parameters you're binding -- that's where the values come from. However, in your example, you've got one question mark but then you try to bind five parameters:

    $stmt1 = mysqli_prepare(
        "SELECT ... FROM cert JOIN courses WHERE cert_id = ? AND course_id = certificate_id"
        $cert_id, certificate_id, $name_student, $hours_com, $course_title

    You seem to want this:

    点赞 评论 复制链接分享