我的网站上有一些PHP代码,当我尝试访问它时会产生500错误。我相信这是我用$ dom-> loadXML($ file)做的事情。
这是edit_test.php
<?php
include_once('xmlSplit.php');
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../assets/app.css">
</head>
<body>
<table>
<?php
foreach($output as $Test_Step){?>
<tr>
<td class="editform">
<input type="number" style="width: 30px;" value="<?php echo trim($Test_Step[1]); ?>" onblur="update_<?php echo trim($Test_Step[1]); ?>()" id="Test_Step_Number_<?php echo trim($Test_Step[1]); ?>">
</td>
<td class="editform">
<textarea class="editor" id="Test_Step_Description_<?php echo trim($Test_Step[1]); ?>" onblur="update_<?php echo trim($Test_Step[1]); ?>()"><?php echo trim($Test_Step[2]); ?></textarea>
</td>
<td class="editform">
<textarea class="editor" id="Test_Step_Expected_<?php echo trim($Test_Step[1]); ?>" onblur="update_<?php echo trim($Test_Step[1]); ?>()"><?php echo trim($Test_Step[3]); ?></textarea>
</td>
<td class="editform">
<button id="deletestep_<?php echo trim($Test_Step[1]); ?>" class="SquareDelete" onclick="delete_<?php echo trim($Test_Step[1]); ?>()">
</button>
</td>
</tr>
<?php
$Additional_id = trim($Test_Step[1]) + 1;
}
?>
<tr>
<td class="editform">
<input type="number" style="width: 30px;" id="New_Step_Number" placeholder="#" value="<?php echo $Additional_id; ?>">
</td>
<td class="editform">
<textarea class="editor" id="New_Step_Description" placeholder="New Step Description"></textarea>
</td>
<td class="editform">
<textarea class="editor" id="New_Step_Expected" placeholder="New Step Expected Result"></textarea>
</td>
<td class="editform">
<input type="submit" class="largeRectButton" value="Add Step" id="insert_new_step" onclick="insert_new_step()">
<br />
<input type="submit" class="largeRectButton" value="Save And Exit" id="insert_new_step" onclick="saveChanges()">
</td>
</tr>
</table>
</body>
使用include来包含文件xmlSplit.php:
<?php
//Decide which version of the file that we need to open
if(isset($_GET['mode'])){
//Give the variables an easier name
$mode = $_GET['mode'];
$file = $_GET['file'];
if($mode == 1){
//This will open the blank test case
$file = ('../files/tests/' . $file . '.txt');
} elseif($mode == 2){
//This will open a previous test run
$file = ('../files/test_runs/' . $file . '.txt');
} else {
echo "ERROR: 2 - Mode not recognised";
die();
}
} else {
echo "ERROR: 1 - Mode not specified";
die();
};
$xml = file_get_contents($file);
$indexes = [];
$numbers = [];
$descriptions = [];
$expecteds = [];
$run_times = [];
$run_statuses = [];
$observations = [];
$comments = [];
$output = [];
$dom = new DOMDOCUMENT;
$dom->loadXML( $xml );
foreach( $dom->getElementsByTagName( 'index' ) as $item ) {
$indexes[] = $dom->saveXML( $item );
}
foreach( $dom->getElementsByTagName( 'number' ) as $item ) {
$numbers[] = $dom->saveXML( $item );
}
foreach( $dom->getElementsByTagName( 'description' ) as $item ) {
$descriptions[] = $dom->saveXML( $item );
}
foreach( $dom->getElementsByTagName( 'expected' ) as $item ) {
$expecteds[] = $dom->saveXML( $item );
}
foreach( $dom->getElementsByTagName( 'run_time' ) as $item ) {
$expecteds[] = $dom->saveXML( $item );
}
foreach( $dom->getElementsByTagName( 'expected' ) as $item ) {
$expecteds[] = $dom->saveXML( $item );
}
foreach( $dom->getElementsByTagName( 'observations' ) as $item ) {
$observations[] = $dom->saveXML( $item );
}
foreach( $dom->getElementsByTagName( 'run_status' ) as $item ) {
$run_statuses[] = $dom->saveXML( $item );
}
foreach( $dom->getElementsByTagName( 'run_time' ) as $item ) {
$run_times[] = $dom->saveXML( $item );
}
foreach( $dom->getElementsByTagName( 'review' ) as $item ) {
$comments[] = $dom->saveXML( $item );
}
foreach($indexes as $index){
//Make the indexes readable
$index = substr($index, 7, -8);
$index = trim(preg_replace('/\s\s+/', ' ', $index));
//Parse things so it's just the values without the tags
$number = substr($numbers[$index], 8, -9);
$number = trim(preg_replace('/\s\s+/', ' ', $number));
$description = substr($descriptions[$index], 13, -14);
$description = trim(preg_replace('/\s\s+/', ' ', $description));
$expected = substr($expecteds[$index], 10, -11);
$expected = trim(preg_replace('/\s\s+/', ' ', $expected));
$observation = substr($observations[$index], 14, -15);
$observation = trim(preg_replace('/\s\s+/', ' ', $observation));
$run_status = substr($run_statuses[$index], 12, -13);
$run_status = trim(preg_replace('/\s\s+/', ' ', $run_status));
$run_time = substr($run_times[$index], 10, -11);
$run_time = trim(preg_replace('/\s\s+/', ' ', $run_time));
$comment = substr($comments[$index], 9, -10);
$comment = trim(preg_replace('/\s\s+/', ' ', $comment));
//Push this step to the output
array_push($output, $index);
array_push($output, $number);
array_push($output, $description);
array_push($output, $expected);
array_push($output, $observation);
array_push($output, $run_status);
array_push($output, $run_time);
array_push($output, $comment);
}
//Split the output so they are all matching whats expected
$output = array_chunk($output, 8);
$size = sizeof($output);
//If the debug was set, print it on the screen, otherwise do nothing as we assume this script is running in the background
if(isset($_GET['debug'])){
echo ( "<pre>" . print_r($output, true) . "</pre>");
}
?>
在我的开发服务器(XAMPP)上工作正常,但当我把它放在我的生产&#34;环境,我只是在javascript控制台中得到500内部服务器错误。我不明白为什么。
edit_test.php包含在iframe中。
用于加载不同文件的javascript,这一切都正常,我在开发服务器上没有任何问题。完整的代码可以在github {LINK REDACTED}上找到,如果你想把它放在你自己的开发服务器上看看它看起来一切正常。 (你需要一个mysql数据库服务器连接到,/ database_changes /文件夹中的数据库设置,/ backend_scripts/database_connection.php中的连接
我甚至尝试手动调用xmlSplit.php以及我在网址中需要的所有变量,但我遇到了同样的问题(500内部服务器错误)是PHP正在服务器上运行,版本:
开发:PHP 7.1.9
生产:7.1.8-1
XML的结构正常,所有权限都可以。
我的生产服务器位于{LINK REDACTED},用户名是&#34; tester&#34;用密码&#34;测试&#34;