KenM Posted June 22, 2021 Share Posted June 22, 2021 New to PW and new to PHP, so sorry in advance! I am trying to set up a database connection. I have a small test file in the web root (next to index.php), and if I point my browser at that I can connect to my database. If I take the same lines of php code and insert them into a template file that I want to use (asset-register.php), it gives me a fatal error with Class 'mysqli' not found in site/templates/asset-register.php:56 What am I missing? I've attached the file, but it is currently just a hack file.. The end goal is to be able to print a report from a database, but I need to be able to connect first! asset-register.php Link to comment Share on other sites More sharing options...
horst Posted June 22, 2021 Share Posted June 22, 2021 (edited) Scope? When in the template file are you in Namespace\Processwire Have you tried to call it with a backslash in front? new \mysqli ... ? EDIT: Yes it is the missing backslash. (downloaded and looked into your php file) ? Edited June 22, 2021 by horst 1 Link to comment Share on other sites More sharing options...
KenM Posted June 22, 2021 Author Share Posted June 22, 2021 Perfect. Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now