简体   繁体   English

OpenTBS / php输出问题

[英]OpenTBS/php problems with output

I've writing a php application on a LAMP server that takes a document(.odt) and populates it with the right information in the appropriate spots. 我已经在LAMP服务器上编写了一个php应用程序,该文件需要一个document(.odt),并在适当的位置填充正确的信息。 While the code compiles it presents me with a print out of the header on one page and a stream of apparent gibberish on the other as follows: 在编译代码时,它为我呈现了一页上的页眉打印内容,而另一页上的则是明显的乱码,如下所示:

''mimetypeapplication/vnd.oasis.opendocument.textPK?H?1?ᄀҡThumbnails/thumbnail.pngノPNG IHDR?g?゙ᄀルIDATxワ? ''mimetypeapplication / vnd.oasis.opendocument.textPK?H?1?ᄀҡThumbnails/ thumbnail.png ノ PNG IHDR?g?゙ ᄀ ル IDATx ワ? ??﾿?ᄃrҩ?Kヨヒ\\䆻ᄆ ᄊ?l?R ᄂ )?トト?jᄄ& lcハ{??ٲz??ヨovg?6?ᄚ=yoovvv?3ᆵ?R?0B#4tD~?ᄀ+ヘF 5BCL#ミᄀ!ᆭHヘ??ᄂFhネiR#4?ᄅbチ? ??﾿?ᄃrҩ?Kヨヒ\\䆻ᄆ ᄊ?l?R ᄂ )?トト?jᄄ& lc ハ {??ٲz ?? ヨ ovg?6?ᄚ = yoovvv?3 ᆵ?R?0B#4tD 〜?ᄀ + ヘ F 5BCL#ミ ᄀ!ᆭ H ヘ ?? ᄂ Fh ネ iR#4?ᄅ b チ? 1ヘ@jトニリF 5BCL#ミᄀ!ᆭHヘ??ヌヤL?Dᄌă? 1 ヘ @j ト ニ リ F 5BCL#ミ ᄀ!ᆭ H ヘ ?? ヌ ヤ L?D ᄌă? ゙?BツD?~??HgᄂKツ PW゚ᄑロ?ᄉ?>oLR+??쟰?.ᄒ?w????ᄊ8Q???タ??8&ᅠ/フ?Ć??a?8/Wᄄᆬ?,tᆬP[tᄆ캁?Is.!??.7?BN??ᄄ?0\\ツ%ホ>? ツ?B ツ D?〜?? Hg ᄂ K ツ PW ゚ ᄑ ロ?> oLR + ??쟰?。ᄒ?w ???? ᄊ 8Q ??? タ ?? 8&ᅠ / フ?Ć?? a?8 / W ᄄ ᆬ?,t ᆬ P [t ᄆ캁?!! ??。7?BN ?? ᄄ?0 \\ ツ%ホ>? }?!4?テ'0?5ᄌ?xLタ؀?E?ᄌ??x^?4?G?ᆲネ#゙???+ ?<4ロ??ロᄚ<???ラz??ᆬロ?D?ワxk?゙??Fa'フŜ -4ᄚg\\ミ 6z^°??ᄂ?yᄅ } ?! 4?テ'0?5 ᄌ?xL タ؀?E?ᄌ ?? x ^?4?G?ᆲ ネ#゙ ??? + ?<4ロ??ロᄚ<???ラz??ᆬロ?D?ワxk?゙??Fa'フŜ -4ᄚg\\ミ 6z ^°?? ᄂ?y ᄅ

I suspect it might be an encoding issue and I've tried different approaches but so far nothing. 我怀疑这可能是编码问题,并且我尝试了不同的方法,但到目前为止没有任何结果。 I haven't had much luck looking for similar situations online so any suggestions/recommendations/help would be appreciated 我在网上寻找类似情况的机会不多,因此任何建议/建议/帮助都将不胜感激

<?php 

session_start(); 
include 'conn.php'; 

if(empty($_SESSION['username']) || empty($_SESSION['password'])) 
    print("Access to database denied"); 
else { 
    $username = $_SESSION['username']; 
    $password = $_SESSION['password']; 
    $type = $_SESSION['type']; 

    if($type == "admin") { 
        include '../includes/aheader.html'; 
    } 
    if($type == "user") { 
        include '../includes/uheader.html'; 
    } 
    if(isset($_POST["searchButton"])) { 
        print_r($_POST);
        $keyword = $_POST['keyword']; 
        $choice = $_POST['choice'];

    if($choice == "company_name") 
        $sql = $mysqli -> prepare("SELECT * FROM clients WHERE company_name LIKE ?"); 

    if($choice == "project_code") 
        $sql = $mysqli -> prepare("SELECT * FROM clients WHERE project_code LIKE ?"); 

    $keyword = '%'.$keyword.'%'; 
    $sql -> bind_param('s', $keyword); 
    $sql -> execute(); 
    $result = $sql -> get_result(); 

        if(!$result) 
            print("<p>Select query failed</p>"); 
        else { 
            if($result -> num_rows == 0) 
            print("<p>No match found</p>");

        else {
            while($row = mysqli_fetch_array($result)) {
                $company_name = $row['0'];
                $phone = $row['1'];
                $address = $row['2'];
                $approximate_employees = $row['3'];
                $project_code = $row['4'];
                extract($row);
            }

            include_once('tbs_class.php');
            include_once('tbs_plugin_opentbs.php');

            $TBS = new clsTinyButStrong;
            $TBS -> Plugin(TBS_INSTALL, OPENTBS_PLUGIN);

            $TBS -> LoadTemplate('document.odt');
            $TBS -> Show(OPENTBS_FILE, 'document.odt');             

            $TBS -> MergeField('company_name', $company_name);
            $TBS -> MergeField('address', $address);
            $TBS -> MergeField('phone', $phone);

        }
    }
}
    else {
        include '../includes/searchForm.html';
        include '../includes/footer.html';
    }
}
$mysqli -> close();

?> ?>

You have to merge fields before to render the result. 您必须先合并字段,然后才能呈现结果。 And the result must be a file different from the template. 结果必须是与模板不同的文件。

        $TBS = new clsTinyButStrong;
        $TBS -> Plugin(TBS_INSTALL, OPENTBS_PLUGIN);

        // Load the template
        $TBS -> LoadTemplate('document.odt');

        // Merge fields
        $TBS -> MergeField('company_name', $company_name);
        $TBS -> MergeField('address', $address);
        $TBS -> MergeField('phone', $phone);

        // Render the result
        $TBS -> Show(OPENTBS_FILE, 'document_result.odt');             

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM