PHP函数给出服务器错误500
所以我写了一个小的搜索函数,但当我把它包含到我的类中时,我的站点停止运行,并给我一个服务器错误500。 我是OOP&PDO新手,所以我不确定我是否犯了一般性错误,或者只是某个地方的输入错误。如果有人能帮我一把,我将不胜感激 我的职能:PHP函数给出服务器错误500,php,oop,pdo,Php,Oop,Pdo,所以我写了一个小的搜索函数,但当我把它包含到我的类中时,我的站点停止运行,并给我一个服务器错误500。 我是OOP&PDO新手,所以我不确定我是否犯了一般性错误,或者只是某个地方的输入错误。如果有人能帮我一把,我将不胜感激 我的职能: <?php public function searchFullTextPanel($q) { try { $stmt=$this->db->prepare("SELECT id,firstname,lastnam
<?php
public function searchFullTextPanel($q)
{
try
{
$stmt=$this->db->prepare("SELECT id,firstname,lastname,adresse_str,adresse_plz,adresse_ort,adresse_land,telefon,email,image_name FROM partner WHERE MATCH (firstname,lastname,adresse_str,adresse_plz,adresse_ort,adresse_land,telefon,email) AGAINST q=:q ");
$stmt->bindparam(":q",$q);
$stmt->execute();
if($stmt->rowCount()>0)
{
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
?>
<tr>
<td><?php print($row['id']); ?></td>
<td><img src="../cv-imgs/<?php print($row['image_name']); ?>" height="42" width="42"></td>
<td><?php print($row['firstname']); ?></td>
<td><?php print($row['lastname']); ?></td>
<td><?php print($row['email']); ?></td>
<td align="center">
<form name="editPartner" method="post" action="anlegen.php"><input type="hidden" name="id" value="<?php print($row['id']); ?>"><button type="submit" name="editPartner"><i style="color: orange" class="glyphicon glyphicon-edit"></i></button></form>
</td>
<td align="center">
<form name="delPartner" method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"><input type="hidden" name="id" value="<?php print($row['id']); ?>"><button type="submit" name="delPartner"><i style="color: red" class="glyphicon glyphicon-remove-circle"></i></button></form>
</td>
</tr>
<?php
}
}
else
{
?>
<tr>
<td>fml...</td>
</tr>
<?php
}
}
}
?>
“height=“42”width=“42”>
其中一个问题是您没有用catch块关闭try块。但也可能有其他问题,请检查服务器上的错误日志。将PHP设置为显示错误。对于某些配置,不会显示错误,仅显示500个错误。将显示错误设置为打开和错误报告设置为E_ALL
(仅用于开发目的)。如果display_errors
打开Off
,则将调度HTTP 500。在try块上必须有catch块来捕获异常,否则try
就没有任何意义。捕获PDOException
try{…}catch(PDOException$E){…}
.Tyvm,是的,是try-block.Tyvm,是的,我修复了它,这是问题的一部分。
<?php
if(isset($_POST['search']))
{
$q = $_POST['q'];
$crud->searchFullTextPanel($q);
}
?>