0

我收到 Notice: Use of undefined constant num - assumed 'num'我的代码所遵循的错误

$query = "SELECT COUNT(*) AS num FROM $tableName";
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];

如何解决这个问题?

我没有合适的头衔,所以请不要把它改成合适的

4

3 回答 3

4

@AkhileshBChandran 给出了一个正确的解决方案。将来,如果您要引用该列,则需要将其放在引号中。

$total_pages = $total_pages['num'];
于 2012-06-30T02:37:02.237 回答
1

$total_pages = $total_pages[0];

于 2012-06-30T02:35:29.323 回答
0
$total_pages = $total_pages['num'];
于 2012-06-30T02:36:47.930 回答