dq804806 2018-08-17 09:28
浏览 85
已采纳

PHP会话不更新变量

I'm building an image slider where images are loaded from my database and displayed inside a php page.

There's a session variable, "number", to remember what is the current database row, in this way I can easily move to next or previous image.

Initially the page was working perfectly, but now when I press on "Next" button to increase session number and move to next page, it remains stuck to "2" and doesn't allow me to read other pages, even if there are multiple ones. I can only browse image no. 1 and image no. 2

I believe the code is correct, but I'm afraid there's something missing about how PHP sessions works, can you confirm it?

//

  • 写回答

2条回答 默认 最新

  • doupo5861 2018-08-17 09:55
    关注

    session_start() must be the second thing on your page after <?php. HTML tags must be placed after it or the session will not be started.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?