Php 未定义变量:FPDF中的pdf

Php 未定义变量:FPDF中的pdf,php,fpdf,Php,Fpdf,这是我使用FPDF显示配置文件图片的代码,我想在没有配置文件图片时显示默认图片。 我使用了一个IFELSE语句,但在else语句中得到了未定义的变量pdf 语句您的问题在于if语句。如果status=1,则定义$pdf。如果不是这样的话,你就不会 您应该沿着这些行重新调整代码 $query = mysqli_query($con,"select * from s_users where s_id = '".$_GET['s_id']."'"); $

这是我使用FPDF显示配置文件图片的代码,我想在没有配置文件图片时显示默认图片。 我使用了一个IFELSE语句,但在else语句中得到了未定义的变量pdf
语句

您的问题在于if语句。如果status=1,则定义$pdf。如果不是这样的话,你就不会

您应该沿着这些行重新调整代码

 $query = mysqli_query($con,"select * from s_users
        where
        s_id = '".$_GET['s_id']."'");   
    $row = mysqli_fetch_array($query);
    if ($row['status'] == 1) { //1 
    $pdf = new PDF_Code128('P','mm','A4');
    $pdf->AddPage();
    $pdf->Cell(190  ,220,'',1,0);
     $pdf->image('images/logo.png', 14, 16, -200);
    $pdf->image($row['imgdata'], 163, 16, -210);
    $pdf->SetFont('Arial','B',14);
    } else {
    $pdf->image('images/profiledefault.jpg', 163, 16, -210);
    }
可能重复的
$query = mysqli_query($con,"select * from s_users where s_id = '".$_GET['s_id']."'");   
$row = mysqli_fetch_array($query);

$pdf = new PDF_Code128('P','mm','A4');
$pdf->AddPage();
$pdf->Cell(190  ,220,'',1,0);

if ($row['status'] == 1) { //1 
    $pdf->image('images/logo.png', 14, 16, -200);
    $pdf->image($row['imgdata'], 163, 16, -210);
} else {
    $pdf->image('images/profiledefault.jpg', 163, 16, -210);
}

$pdf->SetFont('Arial','B',14);