PHP code突然呈现在我的网页,而不是执行 - 没有之前这样做呢? [英] PHP code is suddenly showing up in my web page rather than executing - wasn't doing this before?

查看:171
本文介绍了PHP code突然呈现在我的网页,而不是执行 - 没有之前这样做呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

块或PHP code片突然呈现在我的网页,好像他们是无法被识别为PHP code。我有它的工作之前只是觉得,我不能想什么我已经改变或做的,将已经停止工作了!我花了这么长时间让了Apache,MySQL和PHP摆在首位,现在这方面的工作一起。我已经准备好撕我的头发了!

Blocks or pieces of PHP code are showing up in my web page suddenly as though they are not being recognized as PHP code. I had it working just find before and I can't think of anything I've changed or done that would have stopped it from working! I spent so long getting Apache, MySQL and PHP working together in the first place and now this. I am ready to tear my hair out!!

例1:

示例1 code:
(注意,一个PHP code块显示网页了,而其他的是不是!)

Example 1: Example 1 code: (note that one php code block is showing up in the web page, while the other is not!)

<fieldset>
    <legend>Enter SELECT statement:</legend>
    <textarea name="select" style="width: 100%; margin-bottom: 10px;">
        <?php
            if (isset($_POST['select'])
                echo $_POST['select'];
        ?>
    </textarea>
    <input type="submit" value="Search" />
    <!-- display any sql errors here -->
    <?php
        echo "hello world!";
        if (isset($_POST['select']) {
            if (!$results = mysql_query($_POST['select']))
                die("Error: " . mysql_error());
        }
    ?>
</fieldset>

例2:

Example 2:

例2 code:

<fieldset>
    <legend>Tags:</legend>
    <table class="tagstable">
        <tr class="tagsrow">

        </tr>
        <?php
            $query = "SHOW COLUMNS FROM recipes LIKE 'Tags'";
            if (!($ret = mysql_query($query)))
                die("Error - could not show columns: " . mysql_error());

            if(mysql_num_rows($ret)>0){
                $row=mysql_fetch_row($ret);
                $options=explode("','",preg_replace("/(enum|set)\('(.+?)'\)/","\\2",$row[1]));
            }

            foreach ($options as $tag) {
                echo '<script type="text/javascript">addTag("' . $tag . '", false)</script>';
            }
        ?>
    </table>
    <br>
    <input type="text" id="addtag"><input type="submit" value="Add">
</fieldset>

故障排除:


  • 我的phpinfo();页面按预期工作

  • 包含文件夹的php.exe包括在我的PATH

  • 试图重新启动Apache的

  • 遵循的回答一切步骤,<一个href=\"http://stackoverflow.com/questions/5121495/php-$c$c-is-not-being-executed-i-can-see-it-on-source-$c$c-of-page\">this问题

  • 使用Apache 2.2.22,MySQL服务器5.5.24,PHP 5.4.3,Windows 7中

Apache的httpd.conf包括:

Apache httpd.conf contains:

LoadModule php5_module "c:/websites/php/php5apache2_2.dll"
<IfModule dir_module>
  DirectoryIndex index.html index.htm index.php
</IfModule>
AddType application/x-httpd-php .php
PHPIniDir "C:/websites/php"

凡是离开了我都没有想到的?

Anything left that I haven't thought of??

感谢您!

推荐答案

什么是路径的phpinfo()页面?与此相比,您使用来访问你的脚本的路径。我猜(按当你说的php.exe包含在我的道路),就是你不是在访问在Web根文件,而是试图通过文件系统直接访问它。您需要通过网络服务器来访问它。如果你这样做的权利,它可能会是这样的:

What's the path to the phpinfo() page? Compare that to the path that your using to access your script. My guess (by when you say that "php.exe is included in my PATH"), is that you aren't accessing the file in your web root, but rather trying to directly access it through the file system. You need to access it through the webserver. If you do this right, it will probably look like:

http://localhost/myscript.php

这篇关于PHP code突然呈现在我的网页,而不是执行 - 没有之前这样做呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆