core icon indicating copy to clipboard operation
core copied to clipboard

Uncaught Error: Call to a member function prepare()

Open ghost opened this issue 6 years ago • 4 comments

Just installed Form Tools 3.0.10, have been having this issue for months every time I've tried to install, haven't wanted to bother you so I'd give up and shelve the idea for a while, but I've seen some similar issues discussed on here, however unfortunately none of the advice has solved my problem.

My error log is filled with this error:

[Wed Jan 16 01:01:50.818827 2019] [php7:error] [pid 25204:tid 140562216748800] [client 24.225.14.127:55244] PHP Fatal error: Uncaught Error: Call to a member function prepare() on null in [path]/global/code/Database.class.php:71\nStack trace:\n#0 [path]/global/code/Hooks.class.php(238): FormTools\Database->query('\n SE...')\n#1 [path]/global/code/Hooks.class.php(134): FormTools\Hooks::getHookCalls('start', 'code', 'FormTools\\User-...')\n#2 [path]/global/code/User.class.php(332): FormTools\Hooks::processHookCalls('start', Array, Array)\n#3 [path]/admin/forms/add/index.php(13): FormTools\User->checkAuth('client')\n#4 {main}\n thrown in [path]/global/code/Database.class.php on line 71, referer: [path]/admin/forms/

All the times have been similar in what has happened. Got a 500 error on stage 6 of the install, go to the address and it shows a 500 error. If I try reloading a few times the login page eventually shows, and I'm able to log-in, so the error apparently wasn't a big deal. Navigating through, it's hit and miss, I don't know that there's any page that works reliably, some that I can't get to work at all, but a lot of them that give a 500 error, but if I hit F5 a few times I can eventually get to load.

ghost avatar Jan 16 '19 06:01 ghost

Thanks for posting this @ktululives, the "call to a a member function prepare()" error is very generic (it can occur on a DB query for a variety of reasons) so unfortunately there have been lots of posts that include that, but for different reasons.

From what you described - inconsistently loading pages - that's pretty unique...! Off the top of my head I can't think why pages would sometimes run, sometimes not, besides the DB connection being flakey - and that I've never seen.

Any chance I could see this issue directly & debug on your server? If so, email me at [email protected]. (I can't look at it until the weekend, though - just a heads up).

benkeen avatar Jan 17 '19 05:01 benkeen

Sure, I'll send you an email sometime tomorrow.

Thanks for your help

ghost avatar Jan 17 '19 06:01 ghost

I got to thinking about the database, and deleted my config and set it up using a database on another server and it worked fine, so that narrows it down to my host. I played around with different config settings - I set $g_default_error_reporting to 2047, tried setting $g_session_type to database, and tried fiddling with $g_sql_strict_mode to on and off. This has made no difference, although today I'm noticing that the problem is even more intermittent, although it does seem like maybe a pattern has emerged. I can go to it, and the page loads fine, I can log-in fine, and view 2-3 pages without problem and then it starts giving 500 errors, but again if I f5 (sometimes a few times, sometimes a dozen or more) the page will eventually load.

I'm on php 7.1.20 and mysql 5.7.16. I've never had database problems with this host before using scripts such as wordpress and phpBB. Is it possible that it could be related to some type of fortifacation my host has put in place? I'll contact my host, but I'm not even where to start to describe the problem to them. If you'd still like to take a look, I'll try to remember to send you an email tomorrow afternoon when I have some time.

Thanks again for your help.

ghost avatar Jan 18 '19 05:01 ghost

Similar problem for me, not on the Instalation but on the Add Form process Linked Issue: https://github.com/formtools/core/issues/803 I'm using MariaDB.

russellfeeed avatar Jun 30 '21 07:06 russellfeeed