我无法理解为什么我的PHP代码无法正常工作。请看这个小代码。
<?php
if (!isset($_POST['Ingest']) && !isset($_POST['Play']) && !isset($_POST['Remove'])) {
?>
<html>
<head>
<title> Welcome to VASE Content Management System </title>
</head>
<body>
<form method="post" action="<? php echo $PHP_SELF;?>">
Ingest <br />
Path to video master file:<input type="text" size="80" maxlength="80" name="FileNameIn"> <br />
Target Object Name:<input type="text" size="80" maxlength="80" name="ObjectNameIn"><br />
Resolution of Master:<input type="text" size="80" maxlength="80" name="ResolutionIn"><br />
Codec of Master:<input type="text" size="80" maxlength="80" name="CodecIn"><br />
<input type="submit" value="Ingest" name="Ingest"><br />
Play <br />
Object Name:<input type="text" size="80" maxlength="80" name="ObjectNamePl"><br />
<input type="submit" value="Play" name="Play"><br />
Remove <br />
Object Name:<input type="text" size="80" maxlength="80" name="ObjectNameRm"><br />
<input type="submit" value="Remove" name="Remove"><br />
</form>
<?php
}
elseif (isset($_POST['Ingest'])) {
echo "hi";
}
elseif (isset($_POST['Play'])) {
echo "play";
}
elseif (isset($_POST['Remove'])) {
echo "remove";
}
?>
纯HTML部分,如果复制到单独的HTML文件,工作正常,但PHP代码不起作用。我尝试了另一个PHP示例代码,但这工作正常,所以我的PHP服务器启动并运行正常。我正在使用Ubuntu 11.10。
错误:
500内部服务器错误
服务器遇到意外情况,导致无法完成请求
答案 0 :(得分:2)
,您将操作设置为
<? php echo $PHP_SELF;?>
把空间从?和PHP ...看看会发生什么。
答案 1 :(得分:0)
语法错误:
<form method="post" action="<? php echo $PHP_SELF;?>">
应该是
<form method="post" action="<?php echo $PHP_SELF; ?>">
答案 2 :(得分:0)
在第9行的代码中,删除<?
和php
之间的空格
<?php
if (!isset($_POST['Ingest']) && !isset($_POST['Play']) && !isset($_POST['Remove'])) {
?>
<html>
<head>
<title> Welcome to VASE Content Management System </title>
</head>
<body>
<form method="post" action="<?php echo $PHP_SELF;?>">
Ingest <br />
Path to video master file:<input type="text" size="80" maxlength="80" name="FileNameIn"> <br />
Target Object Name:<input type="text" size="80" maxlength="80" name="ObjectNameIn"><br />
Resolution of Master:<input type="text" size="80" maxlength="80" name="ResolutionIn"><br />
Codec of Master:<input type="text" size="80" maxlength="80" name="CodecIn"><br />
<input type="submit" value="Ingest" name="Ingest"><br />
Play <br />
Object Name:<input type="text" size="80" maxlength="80" name="ObjectNamePl"><br />
<input type="submit" value="Play" name="Play"><br />
Remove <br />
Object Name:<input type="text" size="80" maxlength="80" name="ObjectNameRm"><br />
<input type="submit" value="Remove" name="Remove"><br />
</form>
<?php
}
elseif (isset($_POST['Ingest'])) {
echo "hi";
}
elseif (isset($_POST['Play'])) {
echo "play";
}
elseif (isset($_POST['Remove'])) {
echo "remove";
}
?>
答案 3 :(得分:0)
“解析错误:语法错误,第9行{file}中的意外T_ECHO”
尝试启用error_reporting(E_ALL);