Welcome Guest, Not a member yet? Register   Sign In
Help! needed with a database problem.

Hi, everyone!

I´m new user of CI, found it just couple of days ago and was really
excited about it because I have done PHP without any framework and Jeffrey Way´s video tutorials hit me how much efficient it will be with CI. But now I got this really annoying problem with databases. I can´t get connection between CI and database. I´m using my school's server via SSH from my home and this server supports sqlite3 but I just can´t get it work.

I got the latest version of CI(1.7.2.) so do i still have to make a special setup like this:


I have tried it, but it doesn´t work. I just could not find PHP.ini from my computer, so I made it with text editor and save it to c:/windows/system32 It just got these two lines:


Is that right?

My setups in applications/gonfig/database.php are like this at the moment:

$active_group = "default";
$active_record = TRUE;

$db['default']['hostname'] = "localhost";
$db['default']['username'] = "";
$db['default']['password'] = "";
$db['default']['database'] = 'sqlite:/treeni';
$db['default']['dbdriver'] = "pdo";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

"treeni" is the name of my sqlite3 database and it´s located in a same folder where a CI index.php is in my server. I have tried honestly maybe 100 different combinations for those settings..no luck. Most of the time I get just a blank page, but with these settings
I get error like this:

A Database Error Occurred

SQLSTATE[HY000] [14] unable to open database file

I know my server supports sqlite3 & PHP5 and I got all the rights(read/write/execute for owner/group/other) for this database file.

Got so frustrated with the sqlite that I downloaded postgreSQL, can´t make that work either. I guess the problem with postgreSQL is that it´s located in my computer not in the server where the CI files are?

I would be very happy if someone could figure this out. It would be a shame stop my CI learning here just because this little problem that I can´t make any connection with CI and database.


Hi kidrok and welcome to the CI forums.

I think you're making yourself confused here, with the various bits and bobs.

I'd suggest that you hunt down a copy of XAMPP (?) or something similar, perhaps even set up a virtual machine on your home computer (Microsoft something, I gather) to play with CI on. In either case, you'll be a lot better off once you control the environment you're working in.

Accessing your school's server with SSH is good - but you'd have to make sure the PHP instance on the server was set up to load the pdo_sqlite stuff. The changes you make to a new file called php.ini on your computer at home won't make any difference to what the server at school is doing.

You could check, using your shell, if the school server is already running something more useful - such as mysql:

$ ps aux | grep mysql

(You're looking for something like mysqld_safe already running.)

Of course it's possible your school server has mysql running on a separate dedicated box, or that even if it's running a database server that you need to have a database created for you first - you'd have to check with the admins of the box. It's unlikely they'd provide sqlite, but not a real database instance for you to use.

for virtual machines look at virtual box (free) and vmware server (v2 is free and there are loads of appliances freely downloadable - some with complete server setups)

running XAMPP or a virtual machine on your local computer would be the most reliable way to do things.

Thank you for your posts!

With your line:

$ ps aux | grep mysql

in a SSH I get line like this:

iljokrur 17099 0.0 0.0 61144 648 pts/226 S+ 10:28 0:00 grep mysql

Don´t really know what does it mean? All I know is that "iljokrur" is my username.

Setting up a virtual machine could solve my problem for now, but eventually I will want to move some of my creations online and then I would have this same problem with databases?


[quote author="kidrok" date="1252845344"]
in a SSH I get line like this:

iljokrur 17099 0.0 0.0 61144 648 pts/226 S+ 10:28 0:00 grep mysql

ps shows you all processes currently running, and the grep is a regular expression matcher.

So, what happens here is that grep is in itself a process - consequently it matches that when it finds it. This is a common 'problem' on *nix systems using this frequently-used construct, and is completely normal.

What it does mean is that you don't have a MySQL server running on that box. You could still try running 'mysql' at the commandline and see what happens, just in case. It's possible that they've got their databases on another machine - but really, at this point I'd be just asking your admins about getting access to a MySQL database and/or setting up my own virtual machine. The latter, as has been pointed out, are easy to set up - there's lots of ready-made boxes ready to go (it just means a hefty download - but still smaller than the most recent Battlefield 2 patch (2GB - far out!)). I digress.

And, yes, one day you'll have to move away from a local installation - but trust me, you don't want to move onto a sqlite system. Plus, you'll always want a local instance to develop on. Hosting on a box that provides PHP & MySQL is a only few (insert preferred currency here)'s a month anyway.

yep, thanks again.

I guess I will install XAMPP. Uploading the basic CI files to server via SSH takes about 5-10min so it´s not that smart way of doing these things anyway.

I got small host space(100 MB) for 0,95e/month but with no PHP or MySQL. With those features and 500 MB disk space it will be 3,95e/month so I will upgrade my account when I really need it.

Cheers' from Finland.

Made it work with XAMPP!

Theme © iAndrew 2016 - Forum software by © MyBB