首页 > 解决方案 > PHP7中数组到字符串的转换问题

问题描述

我正在为我工​​作的公司建立一个技术评估系统。当我将它上传到在线主机时,出现“数组字符串转换”错误。

注意:第 4 行 /storage/ssd5/805/10576805/public_html/UI/data.php 中的数组到字符串转换 注意:未定义属性:/storage/ssd5/805/10576805/public_html/UI/ 中的 UserData::$Array第 4 行的 data.php 致命错误:未捕获的错误:函数名称必须是 /storage/ssd5/805/10576805/public_html/UI/data.php:4 中的字符串 堆栈跟踪:在 /storage/ 中抛出 #0 {main} ssd5/805/10576805/public_html/UI/data.php 在第 4 行

我试图在 PHP5 中运行该程序,直到它工作的旧版本的 PHP。但是在 PHP7 到最新版本中不起作用。我认为PHP7的数组转换有新的语法。你能帮我解决这个问题吗?非常感谢。

数据.php

<?php
$process = new UserData();

if(isset($_GET['q'])){

    $process->$_GET['q'](); //this line have an error

}

class UserData {

    function deletePending(){
        require '../config.php';

        $trans_no = $_GET['trans_no'];
        $q = $connection->query("delete from tevaluation where TRANS_NO='$trans_no'");

        return $q;
    }

}
?>

查看.php

<html>
<head>
<title>
 Technical Evaluation
</title>
</head>
<body>
<?php
include 'data.php';
$data = $process->pendingEvaluation();
?>
<table class="table table-hover" id="itemList">
<thead class="bg-primary">
<tr>
    <th class="text-center" width="35">TE #</th>
    <th class="text-center" width="10">QUANTITY</th>
    <th class="text-center" width="10">UNIT</th>
    <th class="text-center" width="20">DESCRIPTION</th>
    <th class="text-center" width="20">DEPARTMENT</th>
    <th class="text-center" width="130">DATE EVALUATED</th>
    <th class="text-center" width="50">STATUS</th>
    <th class="text-center">ACTION</th> 
</tr>
</thead>
<tbody>
    <?php if($data->num_rows > 0): ?>
        <?php while($row = mysqli_fetch_array($data)): ?>
        <?php if($row['STATUS'] == 2): 
        $stat = "<p class='text-danger'><b> For Approval</b></p>";
                    ?>
 <tr>
<td class="text-center" width="15"><?php echo $row['TRANS_NO']; ?></td>
<td class="text-center" width="10"><?php echo $row['QTY']; ?></td>
<td class="text-center" width="10"><?php echo $row['UNIT']; ?></td>
<td class="text-center" width="40"><?php echo $row['DESCRIP']; ?></td>
<td class="text-center" width="20"><?php echo $row['DEPT']; ?></td>
<td class="text-center" width="130"><?php echo $row['E_DATE']; ?></td>
<td class="text-center" width="50"><?php echo $stat; ?></td>
<td>

<a href="data.php?q=deletePending&trans_no=<?php echo $row['TRANS_NO']; ?>" class="btn btn-danger btn-sm" title="Click to Delete">
                                    <span class="fa fa-trash"></span><b> Delete</b>
                                </a>
</td>
</tr>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
</tbody>
</table>
</body>
</html>

标签: phphtml

解决方案


推荐阅读