我在PHP中滥用fetch()吗?

时间:2019-03-29 18:03:59

标签: php mysql sql

我有以下PHP代码。我正在尝试执行SQL查询,但似乎给了我一个错误:

<?php
$dbp = new PDO('mysql:host=localhost;dbname=cisc332x_dev', "cisc332x_root", "pass1pass1");
$revST = ($dbp->query("SELECT SUM(fee) AS rev FROM Attendee WHERE type = 'student'"))->fetch()['rev'];
echo "<tr><td>Students</td><td align='right'>$".$revST."</td></tr>";
$revPR = ($dbp->query("SELECT SUM(rate) AS rev FROM Attendee WHERE type = 'professional'"))->fetch()['rev'];
echo "<tr><td>Professionals</td><td align='right'>$".$revPR."</td></tr>";
?>

我在PHP中滥用fetch()吗?我想念什么?

0 个答案:

没有答案