Why I get 500 Error while on XAMPP while loading CodeIgniter 3 database library? - codeigniter-3

I have gone through number of threads on stackoverflow and on other forums to find the answer but could not find relevant answer. People have applied different approaches but none has worked for me thus far.
I am using CI 3 on XAMPP and whenever I load database library in the model, I run into 500 Error.
Here is my CI database config info:
'hostname' => 'localhost',
'username' => 'my_user',
'password' => 'my_pass',
'database' => 'prod_db',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
PHP ini db libraries are as below:
extension=php_bz2.dll
extension=php_curl.dll
extension=php_fileinfo.dll
;extension=php_ftp.dll
extension=php_gd2.dll
extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
extension=php_mbstring.dll
extension=php_exif.dll ; Must be after mbstring as it depends on it
extension=php_mysqli.dll
;extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client
;extension=php_openssl.dll
;extension=php_pdo_firebird.dll
extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll
;extension=php_shmop.dll
; The MIBS data available in the PHP distribution must be installed.
; See http://www.php.net/manual/en/snmp.installation.php
;extension=php_snmp.dll
My model code is as below:
class loginmodel extends CI_Model {
public function validate_login($username, $password) {
$this->load->database();
$var = 0;
return $var;
}
}
Whenever I remove $this->load->database(); from the model, my code runs and i am able to redirect to a "Login Failed" page. BUT, whenever I load my database library in autoload.php or load it in above model, code fails.
Autoload.php
$autoload['libraries'] = array('database');
Apache error logs showed below errors but I could not figure as why this was happening.
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\php\\ext\\php_mysqli.dll' - The specified module could not be found.\r\n in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\php\\ext\\php_pdo_mysql.dll' - The specified module could not be found.\r\n in Unknown on line 0
Please advise.
EDIT:
I verified all config to be OK and as stated in the comments, I added environment variables to windows and verified through PHPInfo that mysqli and mysqlnd were loaded.

Despite getting all the config right, error still persisted and I did a clean install of CI to reproduce library load failure. This time CI returned an error that db access was denied.
I then realized that after migration, database user was not created in the new environment. So once I created the desired user and assigned it required privileges, I was able to run the code just fine.
Therefore, if anyone encounters such issue in future, below steps might help:
First and foremost, verify if your desired user can access the
database.
Modify your .htaccess to use your desired URL schemes only after
verifying that database connection is working
Then verify that absolute path is available in PHP.ini on XAMPP.
Plus, verify that PHP is added in the environment variables. My
Values on Windows 10 are as follows: Variable Name: PHP , Variable
Value: C:\xampp\php\ext
In CI, mysqli is selected as database driver
In PHP.ini mysqli extension is enabled. i.e. php_mysqli.dll
Echo PHPInfo to verify that mysqli and mysqlnd are available in your
installation.
If nothing works, do a clean install of CI on a separate directory and load database library after setting up your database configuration and before setting up .htaccess until you can reproduce the error.
Hope that error will be eliminated!

Related

JPAM Configuration for Apache Drill

I'm trying to configure PLAIN authentification based on JPAM 1.1 and am going crazy since it doesnt work after x times checking my syntax and settings. When I start drill with cluster-id and zk-connect only, it works, but with both options of PLAIN authentification it fails. Since I started with pam4j and tried JPAM later on, I kept JPAM for this post. In general I don't have any preferences. I just want to get it done. I'm running Drill on CentOS in embedded mode.
I've done anything required due to the official documentation:
I downloaded JPAM 1.1, uncompressed it and put libjpam.so into a specific folder (/opt/pamfile/)
I've edited drill-env.sh with:
export DRILLBIT_JAVA_OPTS="-Djava.library.path=/opt/pamfile/"
I edited drill-override.conf with:
drill.exec: {
cluster-id: "drillbits1",
zk.connect: "local",
impersonation: {
enabled: true,
max_chained_user_hops: 3
},
security: {
auth.mechanisms: ["PLAIN"],
},
security.user.auth: {
enabled: true,
packages += "org.apache.drill.exec.rpc.user.security",
impl: "pam",
pam_profiles: [ "sudo", "login" ]
}
}
It throws the subsequent error:
Error: Failure in starting embedded Drillbit: org.apache.drill.exec.exception.DrillbitStartupException: Problem in finding the native library of JPAM (Pluggable Authenticator Module API). Make sure to set Drillbit JVM option 'java.library.path' to point to the directory where the native JPAM exists.:no jpam in java.library.path (state=,code=0)
I've run that *.sh file by hand to make sure that the necessary path is exported since I don't know if Drill is expecting that. The path to libjpam should be know known. I've started Sqlline with sudo et cetera. No chance. Documentation doesn't help. I don't get it why it's so bad and imo incomplete. Sadly there is 0 explanation how to troubleshoot or configure basic user authentification in detail.
Or do I have to do something which is not told but expected? Are there any Prerequsites concerning PLAIN authentification which aren't mentioned by Apache Drill itself?
Try change:
export DRILLBIT_JAVA_OPTS="-Djava.library.path=/opt/pamfile/"
to:
export DRILL_JAVA_OPTS="$DRILL_JAVA_OPTS -Djava.library.path=/opt/pamfile/"
It works for me.

How to resolve undef error in ejabberd hook

I have added a customized module named mod_confirm_delivery in ejabberd which has compiled and added successfully but when i am sending a message an error is coming in my ejabberd error log file, That is:
2016-03-15 17:03:38.306 [error] <0.2653.0>#ejabberd_hooks:run_fold1:368 {undef,[{mod_confirm_delivery,send_packet,[{xmlel,<<"iq">>,[{<<"xml:lang">>,<<"en">>},{<<"type">>,<<"get">>},{<<"id">>,<<"aacfa">>}],[{xmlcdata,<<"\n">>},{xmlel,<<"query">>,[{<<"xmlns">>,<<"jabber:iq:roster">>}],[]},{xmlcdata,<<"\n">>}]},{state,{socket_state,gen_tcp,#Port<0.58993>,<0.2652.0>},ejabberd_socket,#Ref<0.0.1.25301>,false,<<"12664578908237388886">>,undefined,c2s,c2s_shaper,false,false,false,false,[verify_none,compression_none],true,{jid,<<"test1">>,<<"localhost">>,<<"D-5">>,<<"test1">>,<<"localhost">>,<<"D-5">>},<<"test1">>,<<"localhost">>,<<"D-5">>,{{1458,41617,630679},<0.2653.0>},{2,{{<<"test2">>,<<"localhost">>,<<>>},{{<<"test1">>,<<"localhost">>,<<>>},nil,nil},nil}},{2,{{<<"test2">>,<<"localhost">>,<<>>},{{<<"test1">>,<<"localhost">>,<<>>},nil,nil},nil}},{0,nil},undefined,undefined,{userlist,none,[],false},c2s,ejabberd_auth_internal,{{127,0,0,1},41928},[],active,[],inactive,undefined,undefined,1000,undefined,300,300,false,0,0,true,<<"en">>},{jid,<<"test1">>,<<"localhost">>,<<"D-5">>,<<"test1">>,<<"localhost">>,<<"D-5">>},{jid,<<"test1">>,<<"localhost">>,<<>>,<<"test1">>,<<"localhost">>,<<>>}],[]},{ejabberd_hooks,safe_apply,3,[{file,"src/ejabberd_hooks.erl"},{line,382}]},{ejabberd_hooks,run_fold1,4,[{file,"src/ejabberd_hooks.erl"},{line,365}]},{ejabberd_c2s,session_established2,2,[{file,"src/ejabberd_c2s.erl"},{line,1268}]},{p1_fsm,handle_msg,10,[{file,"src/p1_fsm.erl"},{line,582}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]}
I have ejabberd 16.02.26 and my module code is:
mod_confirm_delivery.erl
This module is working fine with ejabberd 2.1.13 but i want to upgraded my ejabberd. I can't understand what is the problem and how can I resolve this error.
undef error means the function or module is not found. The most likely error is that the mod_confirm_delivery.beam file is not in Erlang VM path.
You should try moving the compiled beam file with other ejabberd beam files or try setting the path used to launch Erlang to the directory where your mod_confirm_delivery.beam file is located. This is the -pa option of the Erlang VM.
If your code if in right place, other option is that the function is undefined. The hook tries to call mod_confirm_delivery:send_packet/4. Your code is wrong as it indeed does not defined send_packet/4 but only send_packet/3. You need to update your code to match new signature for user_send_packet hook:
user_send_packet(Packet, C2SState, From, To) -> Packet
In case of doubt, you can refer to official hook list in ejabberd documentation: https://docs.ejabberd.im/developer/hooks/

Empty pagetree in TYPO3 7.2 backend

I am setting up a web portal using TYPO3 version 7.2. I successfully installed TYPO3 following this article on a Red Hat 4.8.2-16 machine. Everything worked fine and I created some pages until for some reason the pagetree didn't show any content any more. So now the backend looks like this http://goo.gl/3p0uQn
My browsers debug console only returns this error:
TypeError: TYPO3ViewportInstance.DebugConsole is null backend.php:79:5
but I have no idea if this is related to the empty pagetree.
This occurs on Firefox, Chrome and IE, so I guess it has nothing to do with the browser.
Also, I am logged in as an admin so it should not be due to wrong access rights.
Does anybody know what's going on there?
UPDATE:
The TYPO3 Log gives me some PHP Warnings
Core: Error handler (BE): PHP Warning: Cannot modify header information - headers already sent in /var/www/typo3_src-7.2.0/typo3/sysext/core/Classes/Http/AjaxRequestHandler.php line 255
Core: Error handler (BE): PHP Warning: Cannot modify header information - headers already sent in /var/www/typo3_src-7.2.0/typo3/sysext/core/Classes/Http/AjaxRequestHandler.php line 250
Core: Error handler (BE): PHP Warning: Cannot modify header information - headers already sent in /var/www/typo3_src-7.2.0/typo3/sysext/core/Classes/Core/Bootstrap.php line 1193
Core: Error handler (BE): PHP Warning: Cannot modify header information - headers already sent in /var/www/typo3_src-7.2.0/typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php line 439
Core: Error handler (BE): PHP Warning: Cannot modify header information - headers already sent in /var/www/typo3_src-7.2.0/typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php line 438
Core: Error handler (BE): PHP Warning: Cannot modify header information - headers already sent in /var/www/typo3_src-7.2.0/typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php line 425
Core: Error handler (BE): PHP Warning: Cannot modify header information - headers already sent in /var/www/typo3_src-7.2.0/typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php line 424
UPDATE 2
Meanwhile I installed 7.2 completely fresh (even with a new database) and I still get an empty pagetree. I also tried 6.2 LTS, but also here, no pagetree. I'm beginning to think that there is a problem with my PHP settings. Im using PHP 5.6.9 and MariaDB 10.0.19.
Try tu put that on your php.ini :
always_populate_raw_post_data = -1
It worked for me.
Have a nice day.
Raf
You have a PHP error somewhere. Please check your webserver log or php log for error messages. You can also show the error messages by choosing the development preset in the Install Tool or by setting the context environment variable to Development.
Make sure to clear the cache via Install Tool at least once (Important Actions).

Fatal error: Class 'PEAR' not found in /home/user1/public_html/go-pear.php on line 697

When trying to install PEAR by running go-pear.php (from the root of a cPanel GoDaddy hosted account), I get the following error:
Starting installation ... Loading zlib: ok
Bootstrapping Installer...................
Bootstrapping PEAR5.php............(remote) ok
Bootstrapping PEAR.php............(remote) ok
Bootstrapping Archive/Tar.php............(remote) ok
Bootstrapping Console/Getopt.php............(remote) ok
Fatal error: Class 'PEAR' not found in /home/alessio1/public_html/go-pear.php on line 697
line 697 is the following: PEAR::setErrorHandling(PEAR_ERROR_DIE,
"\n%s\n");
The file go-pear.php was taken directly from http://pear.php.net/go-pear without any modification.
What am I doing wrong?
I had the same error, and managed to solve it replacing the links stored in $bootstrap_files to :
$bootstrap_files = array(
'PEAR5.php' => 'https://raw.githubusercontent.com/pear/pear-core/master/PEAR5.php',
'PEAR.php' => 'https://raw.githubusercontent.com/pear/pear-core/master/PEAR.php',
'Archive/Tar.php' => 'https://raw.githubusercontent.com/pear/Archive_Tar/master/Archive/Tar.php',
'Console/Getopt.php' => 'https://raw.githubusercontent.com/pear/Console_Getopt/master/Console/Getopt.php',
);
I also had this error and found that KevinD's fix didn't work for me, but was able to figure something out based on it. To solve the problem I replaced the line
'Console/Getopt.php' => 'https://raw.github.com/pear/Console_Getopt/trunk/Console/Getopt.php',
with
'Console/Getopt.php' => 'https://raw.githubusercontent.com/pear/Console_Getopt/trunk/Console/Getopt.php',
The install completed nearly instantly for me after this change.
Use the .phar file: http://pear.php.net/go-pear.phar
It should work better.
Pay attenction: Sometimes the problem is caused because of the blocking of fsocket() php function.
Server-to-server communication is sometimes used to commit abuses for example internet attacks.
Many free hosting companies block fsocket() function by default, and sometimes you have to authenticate yourself (providing information about you) to use this function.

Sinatra App on Heroku ActiveRecord::StatementInvalid: PGError: ERROR:

SCENARIO:
I currently have anapplication on Heroku that is Sinatra Application + ActiveRecord. What currently works:
• I am able to view static pages of my site
• I am able to run migrations
• I am able to push my local development db to my Heroku DB (heroku db:push postgres://localhost/dev)
• I am able to pull from the Heroku DB down to my localhost DB (heroku db:pull postgres://localhost/dev)
THE ERROR:
When I navigate to a page that makes a simple query like:
#pics = Picture.find(:all)
I get this error in my log file
DEBUG -- : NoMethodError: undefined method `values' for #<PGresult:0x00000002844098>: SHOW client_min_messages
DEBUG -- : PGError: ERROR: invalid value for parameter "client_min_messages": ""
: SET client_min_messages TO ''
ActiveRecord::StatementInvalid - PGError: ERROR: invalid value for parameter "client_min_messages": ""
/app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/postgresql_adapter.rb:592:in `async_exec'
At this point I'm not sure what is wrong so I decided to log onto the heroku console and run this command to see if my tables are in the DB
> heroku console
> ActiveRecord::Base.connection.tables
AND I get a similar errors
ActiveRecord::StatementInvalid: PGError: ERROR: invalid value for parameter "client_min_messages": ""
: SET client_min_messages TO ''
/app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/postgresql_adapter.rb:592:in `async_exec'
/app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/postgresql_adapter.rb:592:in `block in execute'
/app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract_adapter.rb:244:in `block in log'
/app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
Then I decided to try this in the console...
> ActiveRecord::Base.establish_connection
> ActiveRecord::AdapterNotSpecified: ActiveRecord::AdapterNotSpecified
/app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:54:in `establish_connection'
/home/heroku_rack/lib/console.rb:158:in `block (2 levels) in <top (required)>'
/home/heroku_rack/lib/console.rb:148:in `eval'
/home/heroku_rack/lib/console.rb:148:in `_eval'
At this point it would seem that I have no tables and adapter connection but how can that be when I'm able to run migrations and push and pull from the Heroku DB?
UPDATE 1 - NOT MUCH FURTHER ALONG BUT MORE INSIGHT
So I decided to start from scratch and do this over again. I seem to have made some progress but I'm stuck. At re-ran my scenario I mentioned above and succeed. So my database, migration and data are all in the DB. But my app still cannot connect to the DB. BUT what's weird is my console interaction.
> heroku console
> ActiveRecord::Base.connection_config
> {:adapter=>"postgresql", :database=>"1e2e12e21e", :username=>"1e2e12e21e", :password=>"i2j3i23joo12", :host=>"1e2-12e-2e1212-e2e2e1.compute-1.amazonaws.com", :port=>5432, :encoding=>"unicode"}
NOTE: I replaced the real details with this fake stuff just to illustrate
> ActiveRecord::Base.connection_handler
> #<ActiveRecord::ConnectionAdapters::ConnectionHandler:0x00000002f8a578 #connection_pools={"….
NOTE: This a really long string but it has content
> ActiveRecord::Base.connected?
> false
At this point I really don't get it? I don't get how I can keep running db migrations, keeping push and pulling data, log into Heroku Console see my connection_config details, BUT when I run my app internal server error. AND when I run ActiveRecord::Base.connection.tables in heroku console I get ActiveRecord::StatementInvalid: PGError: ERROR: invalid value for parameter "client_min_messages": ""
Any thoughts on what I could be doing wrong?
FINAL UPDATE
Here is what the problem is:
Heroku support kindly pointed to me to a known issue with activerecord 3.1.3. It's a bug that should be fixed in future updates: https://github.com/rails/rails/commit/92a3c487bb0d125c437e53a7f45c31fcca97f2d9
How to solve the problem:
I decided to use a much lower version of activerecord in my gemfile gem "activerecord", "~> 3.0.9 and my site is up and running with no problems so far.
Why I never tried this out before I don't know. I hope this post anyone else.
I had this problem for a long time and it was driving me nuts. I couldn't find a solution anywhere (and many rails updates passed by not solving the "problem"), so i decided to just hunt down the issue myself. It turned out to be an easy fix. Just add an additional key, value pair: :min_messages => "warn" (or whatever message level you want) to the ActiveRecord setup in your configure block. here's what I'm using in my Sinatra app's right now, using Sinatra 1.3.2 and ActiveRecord 3.2.2:
db = URI.parse(ENV['DATABASE_URL'] || "postgres://user:password#localhost/database")
adapter = (db.scheme == "postres") ? "postgresql" : db.scheme
ActiveRecord::Base.configurations[:production] = {
:adapter => adapter,
:username => db.user,
:password => db.password,
:port => db.port,
:database => db.path.sub(%r(^/),""),
:host => db.host,
:min_messages => "warn"
}
unless ActiveRecord::Base.connected?
ActiveRecord::Base.establish_connection ActiveRecord::Base.configurations[:production]
ActiveRecord::Base.logger = Logger.new(STDOUT)
end
hope this helps you and any other people having these issues!
None of the other suggestions worked for me. I ultimately fixed this by switching to the Heroku cedar stack:
heroku create your app --stack cedar
I had this problem on both bamboo-ree-1.8.7 and bamboo-mri-1.9.2 stacks. The application worked fine on localhost, and migrated OK on heroku, but reading the database inside the heroku web stack failed with a client_min_messages complaint.
Setting the :min_messages (as suggested in another answer) to either "warn" or "warning" produced different errors.
Forcing my ActiveRecord down to 3.0.11 (from 3.2.3) resolved the issue. (Not that I see anything in AR to explain this. I speculate it's related to differing postgres versions ... I'm using 9.0.3, suspect the heroku bamboo shared is 8.4)
Pushing this up in my gem file worked for me.
group :production do
gem 'pg'
gem 'activerecord', '~> 3.0.9'
end