Skip to content
Advertisement

“No database selected” when implementing Zebra_pagination with SQL/PHP

Relatively new to PHP and first Stack question, so apologies in advance for any mistakes on my part.

I’m trying to implement Zebra Pagination with my SQL database (using latest MAMP) and getting an error of ‘No database selected’. I think the issue lies in how I’m hooking up my connection with Zebra, but not having a ton of luck debugging. The code:

I’m guessing there’s just some dumb beginner’s mistake in here. Any/all help would be much appreciated!

Advertisement

Answer

I would be sure to test your credentials using the “mysql” command locally or a graphical tool such as Sequel Pro (open source, donationware).

To cite Zebra’s source code:

Please note that this is a generic pagination script, meaning that it does not display any records and it does not have any dependencies on database connections or SQL queries, making it very flexible! It is up to the developer to fetch the actual data and display it based on the information returned by this pagination script. The advantage is that it can be used to paginate over records coming from any source like arrays or databases.

So the issue likely does not lie with Zebra. While it’s possible it is a permissions issue, either way it’s very likely a mis-configuration between your PHP and your MySQL, as referenced here: PHP says “No Database selected” even after using mysqli_select_db()

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement