douao3636 2018-03-22 17:47
浏览 70
已采纳

是什么导致了这个错误? 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 :

if(isset($_GET['cert_id'])){

$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");
$stmt1->bind_param("iisss",$cert_id,$certificate_id,$name_student,$hours_com,$course_title);
$stmt1->execute();
while(mysqli_stmt_fetch($stmt1))
{
  $pdf = new \setasign\Fpdi\Fpdi();
  $pdf->addPage('L');
  $pagecount = $pdf->setSourceFile('cert.pdf');
  $tplIdx = $pdf->importPage(1);
  $pdf->useTemplate($tplIdx);
  $pdf->SetY(-120);
  $pdf->SetX(35);
  $pdf->SetFont('times', 'B', 35);
  $pdf->cell(20, 10,$name_student,  'C');
  $pdf->SetY(-135);
  $pdf->SetX(135);
  $pdf->SetFont('times', 'B', 35);
  $pdf->cell(90, 100, $course_title, 'C');
  $pdf->SetY(151);
  $pdf->SetX(200);
  $pdf->AddFont('BOOKOSBI','','BOOKOSBI.php');
  $pdf->SetFont('BOOKOSBI','',25);
  $pdf->cell(40, 10, $hours_com 'C');

}
$pdf->Output('certnew.pdf','D');

}

line 12 & 13 :

$stmt1->bind_param("iisss",$cert_id,$certificate_id,$name_student,$hours_com,$course_title);
$stmt1->execute();

Any idea what is wrong here?

  • 写回答

1条回答 默认 最新

  • dpw63348 2018-03-22 17:50
    关注

    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(
        $connection,
        "SELECT ... FROM cert JOIN courses WHERE cert_id = ? AND course_id = certificate_id"
    );
    $stmt1->bind_param(
        "iisss",
        $cert_id, certificate_id, $name_student, $hours_com, $course_title
    );
    

    You seem to want this:

    $stmt1->bind_param("i",$cert_id);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置