我收到错误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];
如何解决这个问题?
我没有得到合适的头衔,所以请不要将其改为适合
答案 0 :(得分:4)
@AkhileshBChandran给出了一个正确的解决方案。将来,如果您要引用该列,则需要将其放在引号中。
$total_pages = $total_pages['num'];
答案 1 :(得分:1)
$total_pages = $total_pages[0];
答案 2 :(得分:0)
$total_pages = $total_pages['num'];