Hi everyone,
I’ve just decided to try and write my first extension, which i want to create a unique 10 digit item number for every entry posted in the lone weblog i have, using the “submit_new_entry_absolute_end” hook.
The extension actually works, but it creates a database error for both the front-end and CP of the site, on most pages, saying:
Database Error: Unable to connect to your database. Your database appears to be turned off or the database connection settings in your config file are not correct. Please contact your hosting provider if the problem persists.
If you refresh enough times, it goes away. but will only be permanently suppressed if i delete the entry that I created.
I’ve attached the file for all to see.
Like i say, its my first (and probably poor) effort, but any help would be appreciated!
Thanks,
Leon
Are you invoking a certain function when the database becomes unavailable?
Also, why are you generating a random ID, which is setup as the key for your table? Would it not be simpler to start with a set value and then increment new entries instead of generating a random key each time?
Hi Chris,
You’re right, I’m not quite sure why I went about it that way. I’ve changed it a fair bit and made the whole file a lot simpler.
I am however, still having the database connection issues across the WHOLE site after i have posted an entry with the extension enabled. Once the entry is deleted, everything works fine again.
Does anyone know why this would be?
(i’ve reattached the file)
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.