- 我很难在没有任何输入的情况下请求处理 php 文件。我在 login.php 中使用 PDO 我得到的错误是“无法加载 processing.php,状态:500”。
main.php:-
<head>
<?php require_once '../scripts/login.php';?> //require action
<head>
<body>
<div id='line1'></div>
require(["dojo/request","dojo/domReady!"],
function(request)
{ready(function()
{request('processing.php').then( //request action
function(response){dom.byId(line1).innerHTML=response;},
function(error){alert(error);
});
......
</body>
处理.php:-
<?php
echo "By default, fetch mk7BC data<br/>";
echo
"<table border='1' cellspacing='0' cellpadding='2'>
<tr style='background-color:lightblue; font-weight:normal; font-size:small;'>
<th style='width:40px'>ID</th>
<th style='width:80px'>SN</th>
<th style='width:100px'>Tested</th>
<th style='width:40px'>Jig</th>
<th style='width:80px'>Card</th>
<th style='width:40px'>Batch</th>
<th style='width:40px'>COM</th>
<th style='width:40px'>3rdCOM</th>
<th style='width:40px'>IO34</th>
<th style='width:40px'>Comment</th>
</tr>";
try
(
$dbh-> query('use testdata1970_10');
$color='1';
foreach($dbh->query('call getallusers();') as $row)
{if($color==1)
{echo "<tr style='background-color:lightyellow; font-weight:lighter;
font-size:x-small;'>";
$color='2';
}
else
{echo"<tr style='background-color:lightgreen; font-weight:lighter;
font-size:x-small;'>";
$color='1';
}
echo
"<td>{$row['idtest']}</td>
<td>{$row['SN']}</td>
<td>{$row['time_tested']}</td>
<td>{$row['id_jig']}</td>
<td>{$row['mfg_code']}</td>
<td>{$row['batch_no']}</td>
<td>{$row['com_status']}</td>
<td>{$row['3rdcom_status']}</td>
<td>{$row['IO34_status']}</td>
<td>{$row['comment']}</td>
</tr>";
}
echo "</table>";
)
?>
登录.php:-
<?php
dbname=testdata1970_10;
$dsn = 'mysql:host=localhost; Port=3306';
$user = 'root';
$pswd = '';
$dbh = new PDO($dsn, $user, $pswd,
array(PDO::ATTR_PERSISTENT, TRUE));
$dbh->setAttribute(PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION);
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
?>
请告知谢谢克莱门特