duanduan8439 2015-03-24 21:21
浏览 35
已采纳

PHP包括不在新的LAMP服务器上工作

I am working on converting an application I wrote in .NET over to a LAMP server.

I built a very basic PHP file that connects to a MySQL database and creates a drop-down list of usernames. This works fine by itself, and by executing it from the command line using "PHP -f file.php":

<?php
mysql_connect('localhost', 'user', 'password');
mysql_select_db("database");

$sql = "SELECT Username,Guid FROM Usernames";
$result = mysql_query($sql);

echo "<td><select name='users'>";

while($row = mysql_fetch_assoc($result)){
echo "<option value='" . $row['Guid'] . "'>" . $row['Username'] . "  </option>";
}   

echo "</select></td></tr> ";
?>

HOWEVER, when I try to include this file in an html file, it simply does not display, and I am not getting any errors. Here is the source from the basic HTML file:

<HTML>
<H1>This is my homepage</H1>
<?php 
error_reporting(E_ALL ^ E_NOTICE);
include 'ShowData.php';?>
</HTML>

My question is this: does apache2 natively allow for php include? In my case, both files are in the same directory "/var/www/html/". Or am I missing some base configuration somewhere to allow this? My LAMP server is a brand new install of Ubuntu 14LTS. LAMP was installed using the published "apt-get" commands.

  • 写回答

1条回答 默认 最新

  • duanmi4379 2015-03-24 21:31
    关注

    You can't run php in a .html file change the extension to .php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?