0

我正在开发一个在线报价系统(从头开始)并且由于我的 PHP 页脚中的某些内容而出现异常。

当用户单击提交时,仅当如下所示注释掉对 SQL 数据库的调用块时,才能调用 MMJS/MPJS/DPJS 文档中的函数(接近下面代码的末尾)。否则,我会收到一个异常,说明这些文档中的函数未定义。

为什么此代码块会导致稍后调用的文档中的函数无法访问?

代码:

        <div id="results"></div>

        </div><!-- #wrapper -->

        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
        <script>window.jQuery || document.write('<script src="<?PHP echo $relpath; ?>js/vendor/jquery-1.9.0.min.js"><\/script>')</script>
        <script src="<?PHP echo $relpath; ?>js/plugins.js"></script>
        <script src="<?PHP echo $relpath; ?>js/main.js"></script>

        // <script type="text/javascript">
            // <?PHP
                // $stmt = $mysqli->prepare("SELECT * FROM `Fixed Quoter Prices` WHERE 1");
                // $stmt->bind_result($db_DPbaseRate, $db_MPbaseRate, $db_MMbaseRate, $db_raidRate, $db_boxRate, $db_metaRate, $db_sanRate,$db_hbaRate, $db_twoTB, $db_threeTB, $db_fourTB, $db_switchUpgrade, $db_tenRate, $db_taxRate);
                // $stmt->execute();
                // $stmt->fetch();

                // echo "var DPbaseRate = $db_DPbaseRate;";
                // echo "var MPbaseRate = $db_MPbaseRate;";
                // echo "var MMbaseRate = $db_MMbaseRate;";
                // echo "var raidRate = $db_raidRate;";
                // echo "var boxRate = $db_boxRate;";
                // echo "var metaRate = $db_metaRate;";
                // echo "var sanRate = $db_sanRate;";
                // echo "var hbaRate = $db_hbaRate;";
                // echo "var twoTB = $db_twoTB;";
                // echo "var threeTB = $db_threeTB;";
                // echo "var fourTB = $db_fourTB;";
                // echo "var switchUpgrade = $db_switchUpgrade;";
                // echo "var tenRate = $db_tenRate;";
                // echo "var taxRate = $db_taxRate;";
            // ?>

        // </script>

        <?PHP if($title == 'Media Master') : ?>
        <script type="text/javascript" src="../js/MMJS.js"></script>
        <?PHP elseif($title == 'Media Pro') : ?>
        <script type="text/javascript" src="../js/MPJS.js"></script>
        <?PHP elseif($title == 'Desk Pro') : ?>
        <script type="text/javascript" src="../js/DPJS.js"></script>
        <?PHP endif; ?>

    </body>
</html>
4

1 回答 1

0

弄清楚了!我忘记了我最初的 SQL 数据库连接。

更正了内部脚本,在块引用中添加了一行:

<script type="text/javascript">
            <?PHP

$mysqli = new mysqli('12.34.56.78','someuser','somepass','foo');

                $stmt = $mysqli->prepare("SELECT * FROM `Fixed Quoter Prices` WHERE 1");
                $stmt->bind_result($db_DPbaseRate, $db_MPbaseRate, $db_MMbaseRate, $db_raidRate, $db_boxRate, $db_metaRate, $db_sanRate,$db_hbaRate, $db_twoTB, $db_threeTB, $db_fourTB, $db_switchUpgrade, $db_tenRate, $db_taxRate);
                $stmt->execute();
                $stmt->fetch();

                echo "var DPbaseRate = $db_DPbaseRate;";
                echo "var MPbaseRate = $db_MPbaseRate;";
                echo "var MMbaseRate = $db_MMbaseRate;";
                echo "var raidRate = $db_raidRate;";
                echo "var boxRate = $db_boxRate;";
                echo "var metaRate = $db_metaRate;";
                echo "var sanRate = $db_sanRate;";
                echo "var hbaRate = $db_hbaRate;";
                echo "var twoTB = $db_twoTB;";
                echo "var threeTB = $db_threeTB;";
                echo "var fourTB = $db_fourTB;";
                echo "var switchUpgrade = $db_switchUpgrade;";
                echo "var tenRate = $db_tenRate;";
                echo "var taxRate = $db_taxRate;";
            ?>
        </script>
于 2013-03-31T00:22:21.420 回答