Php fpdf错误和视图表错误

Php fpdf错误和视图表错误,php,html,mysql,fpdf,Php,Html,Mysql,Fpdf,这是两页,未定义的索引出现错误: 文件未定义索引:所以请尝试指出错误,因为当我添加图像字段时,显示了主要错误,然后错误开始弹出 我正在尝试从数据库中获取图像,并尝试以PDF格式显示它。 首先,您应该关闭所有的和标记。第二,您没有在表单中发送任何文件,因此您得到了这个未定义的索引:file error,所以请删除这些行 $file_filename=$_FILES['file']['name']; $target_path = "Newfolder1"; $image_path = $targ

这是两页,未定义的索引出现错误:

文件未定义索引:所以请尝试指出错误,因为当我添加图像字段时,显示了主要错误,然后错误开始弹出

我正在尝试从数据库中获取图像,并尝试以PDF格式显示它。
首先,您应该关闭所有的和标记。第二,您没有在表单中发送任何文件,因此您得到了这个未定义的索引:file error,所以请删除这些行

$file_filename=$_FILES['file']['name'];
$target_path  =  "Newfolder1";
$image_path = $target_path . DIRECTORY_SEPARATOR . "filename";
$image_format = strtolower(pathinfo('filename', PATHINFO_EXTENSION));
所以在用户点击查看按钮后,您应该像这样处理表单和显示图像

// your code

if (isset($_POST['View']) ){
    $pdf=new fpdf();
    $pdf->ADDPage();
    $pdf->setfont('Arial','B', 16);  
    $pdf->Cell(40,10, 'sname',1,0,'c');
    $pdf->Cell(40,10, 'sadd',1,0,'c');
    $pdf->Cell(40,10, 'category',1,0,'c');
    $pdf->Cell(40,10, 'scode',1,0,'c');


    $con = mysqli_connect("localhost","root","","school");
    if (mysqli_connect_errno()){
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }

    $sql="SELECT * FROM imagetable WHERE ID= '$_POST[search]'";
    $result = mysqli_query($con, $sql);
    if(!mysqli_query($con, $sql)){
        die( "Could not execute sql: $sql"); 
    }

    $row = mysqli_fetch_array($result);
    $image_path = $row['file'] . DIRECTORY_SEPARATOR . $row['filename'];  // path should be like this, process/upload/8/cdv_photo_001.jpg
    $image_format = strtolower(pathinfo($image_path, PATHINFO_EXTENSION));
    $pdf->Cell(40,10, $row['sname'],1,0,'c');
    $pdf->Cell(40,10, $row['sadd'],1,0,'c');
    $pdf->Cell(40,10, $row['category'],1,0,'c');
    $pdf->Image($image_path,50,100,50,20,$image_format);
    $pdf->ln();
    $pdf->output();
}

// your code

你到底是从哪里得到这个错误的?指出出现此错误的行首先关闭所有td标记echo…@RajdeepPaul iam在第二页上出现此错误,$file_filename=$_FILES['file']['name']$pdf->Image$Image\u路径,50100,50,20,$Image\u格式;你也在尝试以这种形式上传文件?您没有文件输入,表单设置不正确。我正在尝试从数据库中获取图像并尝试以pdf格式显示它。它现在正在打开pdf,但为空没有图像没有该行的数据只有我在开始时定义的单元格,而且当我从我的pdf代码中删除while循环时,它是空的显示相同的图像错误extension@IshankSainger您只从表中获取一行,因此不需要while循环。还要检查是否从表中获取任何行,请使用mysqli_num_rows函数。我认为您没有从表中获取任何行。它显示图像文件为空,并且有一件事$image_path=$row['file'];--此文件应为路径或文件name@IshankSainger$image_path=$row['file'];应该有图像的完整路径,而不仅仅是目录或文件名,如process/upload/8/cdv_photo_001.jpg
// your code

if (isset($_POST['View']) ){
    $pdf=new fpdf();
    $pdf->ADDPage();
    $pdf->setfont('Arial','B', 16);  
    $pdf->Cell(40,10, 'sname',1,0,'c');
    $pdf->Cell(40,10, 'sadd',1,0,'c');
    $pdf->Cell(40,10, 'category',1,0,'c');
    $pdf->Cell(40,10, 'scode',1,0,'c');


    $con = mysqli_connect("localhost","root","","school");
    if (mysqli_connect_errno()){
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }

    $sql="SELECT * FROM imagetable WHERE ID= '$_POST[search]'";
    $result = mysqli_query($con, $sql);
    if(!mysqli_query($con, $sql)){
        die( "Could not execute sql: $sql"); 
    }

    $row = mysqli_fetch_array($result);
    $image_path = $row['file'] . DIRECTORY_SEPARATOR . $row['filename'];  // path should be like this, process/upload/8/cdv_photo_001.jpg
    $image_format = strtolower(pathinfo($image_path, PATHINFO_EXTENSION));
    $pdf->Cell(40,10, $row['sname'],1,0,'c');
    $pdf->Cell(40,10, $row['sadd'],1,0,'c');
    $pdf->Cell(40,10, $row['category'],1,0,'c');
    $pdf->Image($image_path,50,100,50,20,$image_format);
    $pdf->ln();
    $pdf->output();
}

// your code