[GH-ISSUE #174] creating user: PHP Fatal error: Uncaught Error: Call to a member function prepare() on boolean #141

Closed
opened 2026-02-25 21:34:15 +03:00 by kerem · 10 comments
Owner

Originally created by @nekromoff on GitHub (Mar 17, 2017).
Original GitHub issue: https://github.com/cypht-org/cypht/issues/174

Originally assigned to: @jasonmunro on GitHub.

$ php ./scripts/create_account.php admin admin
PHP Fatal error:  Uncaught Error: Call to a member function prepare() on boolean in /var/www/html/cypht/cypht-master/lib/auth.php:158
Stack trace:
#0 /var/www/html/cypht/cypht-master/scripts/create_account.php(37): Hm_Auth_DB->create('admin', 'admin')
#1 {main}
  thrown in /var/www/html/cypht/cypht-master/lib/auth.php on line 158

Originally created by @nekromoff on GitHub (Mar 17, 2017). Original GitHub issue: https://github.com/cypht-org/cypht/issues/174 Originally assigned to: @jasonmunro on GitHub. ``` $ php ./scripts/create_account.php admin admin PHP Fatal error: Uncaught Error: Call to a member function prepare() on boolean in /var/www/html/cypht/cypht-master/lib/auth.php:158 Stack trace: #0 /var/www/html/cypht/cypht-master/scripts/create_account.php(37): Hm_Auth_DB->create('admin', 'admin') #1 {main} thrown in /var/www/html/cypht/cypht-master/lib/auth.php on line 158 ```
kerem closed this issue 2026-02-25 21:34:15 +03:00
Author
Owner

@jasonmunro commented on GitHub (Mar 17, 2017):

Hello!
Looks like you are missing the required PHP PDO support that we use to access databases:
http://php.net/manual/en/book.pdo.php
It could also be that PDO is installed, but not the driver it needs for your particular database type.

<!-- gh-comment-id:287406728 --> @jasonmunro commented on GitHub (Mar 17, 2017): Hello! Looks like you are missing the required PHP PDO support that we use to access databases: http://php.net/manual/en/book.pdo.php It could also be that PDO is installed, but not the driver it needs for your particular database type.
Author
Owner

@nekromoff commented on GitHub (Mar 17, 2017):

PHP 7.0.15

$ php -m
[PHP Modules]
bcmath
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
imap
intl
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

<!-- gh-comment-id:287433297 --> @nekromoff commented on GitHub (Mar 17, 2017): PHP 7.0.15 $ php -m [PHP Modules] bcmath calendar Core ctype curl date dom exif fileinfo filter ftp gd gettext hash iconv imap intl json libxml mbstring mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql Phar posix readline Reflection session shmop SimpleXML sockets SPL standard sysvmsg sysvsem sysvshm tokenizer wddx xml xmlreader xmlwriter xsl Zend OPcache zip zlib [Zend Modules] Zend OPcache
Author
Owner

@jasonmunro commented on GitHub (Mar 17, 2017):

odd, looks good and matches what I have. Have you double checked your db configuration in the ini file? The error is due to the fact that the expected database connection object is not being created, this could be because of a bad config value or failure to login to the db correctly. Also keep in mind anytime you change your hm3.ini file you have to run the scripts/config_gen.php script again.

<!-- gh-comment-id:287435300 --> @jasonmunro commented on GitHub (Mar 17, 2017): odd, looks good and matches what I have. Have you double checked your db configuration in the ini file? The error is due to the fact that the expected database connection object is not being created, this could be because of a bad config value or failure to login to the db correctly. Also keep in mind anytime you change your hm3.ini file you have to run the scripts/config_gen.php script again.
Author
Owner

@nekromoff commented on GitHub (Mar 17, 2017):

On Fri, Mar 17, 2017 at 10:28 PM, Jason Munro notifications@github.com
wrote:

scripts/config_gen.php

Sorry, somehow I forgot to configure proper database. Anyway, now it seems
to be working to the point of getting this:
$ php ./scripts/create_account.php admin admin
An error occured

When I print out debug log, I get:
[0] => Connecting to dsn: mysql:host=127.0.0.1;dbname=cypht

<!-- gh-comment-id:287439058 --> @nekromoff commented on GitHub (Mar 17, 2017): On Fri, Mar 17, 2017 at 10:28 PM, Jason Munro <notifications@github.com> wrote: > scripts/config_gen.php Sorry, somehow I forgot to configure proper database. Anyway, now it seems to be working to the point of getting this: $ php ./scripts/create_account.php admin admin An error occured When I print out debug log, I get: [0] => Connecting to dsn: mysql:host=127.0.0.1;dbname=cypht
Author
Owner

@jasonmunro commented on GitHub (Mar 17, 2017):

We are getting closer! :) Can you try the following patch?: https://gist.github.com/jasonmunro/470e7e252ff358e5a710aa01e9fb1a81
This will dump errors from the database object to hopefully tell us what is going wrong.
Thanks!

<!-- gh-comment-id:287441442 --> @jasonmunro commented on GitHub (Mar 17, 2017): We are getting closer! :) Can you try the following patch?: https://gist.github.com/jasonmunro/470e7e252ff358e5a710aa01e9fb1a81 This will dump errors from the database object to hopefully tell us what is going wrong. Thanks!
Author
Owner

@nekromoff commented on GitHub (Mar 17, 2017):

Getting this:
Array
(
[0] => 00000
[1] =>
[2] =>
)

BTW, I should have mentioned also this:
While trying to create the database tables, I was getting error about key too long:
Error in query (1071): Specified key was too long; max key length is 767 bytes

I found mention of it here saying that 767 bytes is the key length for InnoDB tables and 1000 bytes for MyISAM.

I thus shortened username field length to 50 in both users and settings tables and hm_id to 100 in session table.

<!-- gh-comment-id:287443502 --> @nekromoff commented on GitHub (Mar 17, 2017): Getting this: Array ( [0] => 00000 [1] => [2] => ) BTW, I should have mentioned also this: While trying to create the database tables, I was getting error about key too long: Error in query (1071): Specified key was too long; max key length is 767 bytes I found mention of it [here](https://stackoverflow.com/questions/1814532/1071-specified-key-was-too-long-max-key-length-is-767-bytes) saying that 767 bytes is the key length for InnoDB tables and 1000 bytes for MyISAM. I thus shortened username field length to 50 in both users and settings tables and hm_id to 100 in session table.
Author
Owner

@jasonmunro commented on GitHub (Mar 17, 2017):

odd that I have not run into that issue before, I have a test setup using InnoDB (but I noticed just now it's setup as varchar(250), not 255). The hm_id in the session table needs to be more than 100, looking at my current session ids they are 172 chars long.

Bummer that the debug did not provide any info, thanks for trying it. I can't reproduce this problem so I wasn't sure what it would do. The "Connecting to dsn: mysql:host=127.0.0.1;dbname=cypht" message means you are successfully connected to the database, so maybe now the issue is permissions on the table itself?

<!-- gh-comment-id:287447856 --> @jasonmunro commented on GitHub (Mar 17, 2017): odd that I have not run into that issue before, I have a test setup using InnoDB (but I noticed just now it's setup as varchar(250), not 255). The hm_id in the session table needs to be more than 100, looking at my current session ids they are 172 chars long. Bummer that the debug did not provide any info, thanks for trying it. I can't reproduce this problem so I wasn't sure what it would do. The "Connecting to dsn: mysql:host=127.0.0.1;dbname=cypht" message means you are successfully connected to the database, so maybe now the issue is permissions on the table itself?
Author
Owner

@nekromoff commented on GitHub (Mar 17, 2017):

I dropped the indexes to allow for the original field lengths and now it works fine.
So, I guess the fields being too short were the problem.

You might want to add error checking for existing user, though, when running create_account.php as when I run it with existing username, I just get "An error occured" message. It could warn me that I was trying to create user that already existed.

Thanks for your help!

<!-- gh-comment-id:287449459 --> @nekromoff commented on GitHub (Mar 17, 2017): I dropped the indexes to allow for the original field lengths and now it works fine. So, I guess the fields being too short were the problem. You might want to add error checking for existing user, though, when running _create_account.php_ as when I run it with existing username, I just get "An error occured" message. It could warn me that I was trying to create user that already existed. Thanks for your help!
Author
Owner

@nekromoff commented on GitHub (Mar 17, 2017):

You might still want to investigate the problem with indexes under InnoDB tables that I ran into, though. Thanks!

<!-- gh-comment-id:287449649 --> @nekromoff commented on GitHub (Mar 17, 2017): You might still want to investigate the problem with indexes under InnoDB tables that I ran into, though. Thanks!
Author
Owner

@jasonmunro commented on GitHub (Mar 17, 2017):

I will see about improving the output on existing users, and definitely research the issue with innodb tables. Thanks for the feedback!

<!-- gh-comment-id:287450064 --> @jasonmunro commented on GitHub (Mar 17, 2017): I will see about improving the output on existing users, and definitely research the issue with innodb tables. Thanks for the feedback!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cypht#141
No description provided.