Welcome Guest, Not a member yet? Register   Sign In
"Undefined Variable" Error after Site Migration
#1

Hello!

I have a website based on CodeIgnitor 3.

I want to change hosting, so I made a SQL dump and a backup of the web root, which I both migrated to the new host.


But I'm getting "Undefined Variable" errors, when I try to load the website on the new host.

It seems to me, that for some reasons, code ignitor is not able to load any data from the database, though there aren't any authentification errors. 

I'm lost atm, since the code itself hasn't changed at all and it worked perfectly on the old host.


If someone recognizes this issue or can give me a hint how to further troubleshoot it, I would be very thankful.

Kind regards,
Chris!
Reply
#2

Hi,

Most likely have you PHP version changed and therefor you application have stopped working.
Those "Undefined Variable" aren't always critical, but should be fixed nonetheless.

Make a private (install a local development machine) copy of the website and log debug messages in /application/config/Config.php.
Reply
#3

that was my first thought.

the original server runs on php 5.6
the new runs on 7.3
first, i tried updating code ignitor system folder to current v3, because i read somewhere, that those version would be compatible with never php versions.
didn't change anything.
so tried to deploy it on another 5.6 stack. but same issue!
i activated log level 4 (all logs), but the logs aren't telling me more then the php error messages in the browser.
Undefined variable warning, then Exception: Call to a member function result() on null
sadly, this breaks the whole site.
it doesn't appear to be related to the php version. so i'm really confused rn.
Reply
#4

CodeIgniter 3 are compatible with PHP 7.3 and users have also tested it with success on PHP 7.4.

If that error message are correct you have an error message regarding a database query. result() can't run without an database object. So I guess you didn't install it correctly. You have configured the database connection?
Reply
#5

i'm Running CI 3 with PHP 7.4. and i have not encountered any error.

seems like the error "Call to a member function result() on null" is from a database result.

my wild guess since you have upgraded to PHP 7.4 there is a chance that mysql was also upgraded. 

If it turns out to be mysql8 or above i think its an error on the caching_sha2_password

you can test by uploading a file on your server which contains a simple database connection.

if not please disregard my reply.

Thanks
Reply
#6

(This post was last modified: 04-22-2020, 12:02 PM by happahappa.)

(04-22-2020, 10:57 AM)jreklund Wrote: CodeIgniter 3 are compatible with PHP 7.3 and users have also tested it with success on PHP 7.4.

If that error message are correct you have an error message regarding a database query. result() can't run without an database object. So I guess you didn't install it correctly. You have configured the database connection?

that's what driving me nuts. the mysql server (mariadb) runs. sql dump restored, privs restored, i can connect to it via mysql, using the same credentials and do everything. also no error messages in the mariadb logs. 

ofc changed the database.php (there was just a new password to enter)

but it still looks like the sql query is exactly what is failing.

it also show error messages if the tables don't exist. (i tried once, after i created the database and the credentials, but didn't yet import the sql dump). so the connection apparently to the mysqlserver apparently works. but there is no difference in the data, between the original mysql server and the imported dump. what on earth is going on here Big Grin
Reply
#7

I think the easiest thing to test out are use a fresh copy CodeIgniter (without any of your code). And try connecting to the database and running a query. If that works, it have something to do with your code I'm afraid.
Reply
#8

the side has been working perfectly for years now. why should migrating it another host require changes to the code? this is very odd.
Reply
#9

Different server with different settings causes different behavior. Sounds perfect legit to me, that you can't run every application everywhere. My development machine are an exact replica of the production environment, so that these things don't happen.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB