PHP代码突然出现在我的网页中而不是执行 – 之前没有这样做过吗?

前端之家收集整理的这篇文章主要介绍了PHP代码突然出现在我的网页中而不是执行 – 之前没有这样做过吗?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
PHP代码的块或部分突然出现在我的网页中,就好像它们没有被识别为PHP代码一样.我之前找到它工作,我想不出任何我改变或完成的任何会阻止它工作的东西!我花了很长时间才开始让Apache,MysqLPHP一起工作,现在这个.我准备撕掉我的头发!!

例1:

示例1代码
(请注意,一个PHP代码显示在网页中,而另一个则没有!)

  1. <fieldset>
  2. <legend>Enter SELECT statement:</legend>
  3. <textarea name="select" style="width: 100%; margin-bottom: 10px;">
  4. <?PHP
  5. if (isset($_POST['select'])
  6. echo $_POST['select'];
  7. ?>
  8. </textarea>
  9. <input type="submit" value="Search" />
  10. <!-- display any sql errors here -->
  11. <?PHP
  12. echo "hello world!";
  13. if (isset($_POST['select']) {
  14. if (!$results = MysqL_query($_POST['select']))
  15. die("Error: " . MysqL_error());
  16. }
  17. ?>
  18. </fieldset>

例2:

示例2代码

  1. <fieldset>
  2. <legend>Tags:</legend>
  3. <table class="tagstable">
  4. <tr class="tagsrow">
  5.  
  6. </tr>
  7. <?PHP
  8. $query = "SHOW COLUMNS FROM recipes LIKE 'Tags'";
  9. if (!($ret = MysqL_query($query)))
  10. die("Error - could not show columns: " . MysqL_error());
  11.  
  12. if(MysqL_num_rows($ret)>0){
  13. $row=MysqL_fetch_row($ret);
  14. $options=explode("','",preg_replace("/(enum|set)\('(.+?)'\)/","\\2",$row[1]));
  15. }
  16.  
  17. foreach ($options as $tag) {
  18. echo '<script type="text/javascript">addTag("' . $tag . '",false)</script>';
  19. }
  20. ?>
  21. </table>
  22. <br>
  23. <input type="text" id="addtag"><input type="submit" value="Add">
  24. </fieldset>

故障排除:

>我的PHPinfo();页面按预期工作
>包含PHP.exe的文件夹包含在我的PATH中
>尝试重启Apache
>按照this question的答案中的所有步骤
>使用Apache 2.2.22,MysqL Server 5.5.24,PHP 5.4.3,Windows 7

Apache httpd.conf包含:

  1. LoadModule PHP5_module "c:/websites/PHP/PHP5apache2_2.dll"
  2. <IfModule dir_module>
  3. DirectoryIndex index.html index.htm index.PHP
  4. </IfModule>
  5. AddType application/x-httpd-PHP .PHP
  6. PHPIniDir "C:/websites/PHP"

还有什么我没有想到的东西?

谢谢!

什么是PHPinfo()页面的路径?将其与您用于访问脚本的路径进行比较.我的猜测(当你说“PHP.exe包含在我的PATH中”时)是你没有访问web根目录中的文件,而是试图通过文件系统直接访问它.您需要通过Web服务器访问它.如果你这样做,它可能看起来像:
  1. http://localhost/myscript.PHP

猜你在找的PHP相关文章