Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqlite error while inserting new record #232

Closed
philippfrenzel opened this issue May 11, 2013 · 16 comments
Closed

sqlite error while inserting new record #232

philippfrenzel opened this issue May 11, 2013 · 16 comments
Labels
status:to be verified Needs to be reproduced and validated. type:bug Bug

Comments

@philippfrenzel
Copy link
Contributor

Database Exception (yii\db\Exception)

SQLSTATE[HY000]: General error: 14 unable to open database file

But, the db is readable and writable! (777)

Source can be found here:
https://github.com/philippfrenzel/frenzelgmbh/blob/master/app/controllers/MessagesController.php

@rusmaxim
Copy link
Contributor

Just get your sources. And create messages. All works ok. So i think problem on your server.

@philippfrenzel
Copy link
Contributor Author

Hi, thank you very much for the debugging, so I have to figure out, what's
wrong with my system Š Should I post the reason?

Von: rusmaxim notifications@github.com
Antworten an: yiisoft/yii2
<reply+i-14219278-5b1ebbaa23be3037bcd2721d7e883988d3240be5-2319890@reply.git
hub.com>
Datum: Samstag, 11. Mai 2013 12:14
An: yiisoft/yii2 yii2@noreply.github.com
Cc: Philipp Frenzel pf@com-x-cha.com
Betreff: Re: [yii2] sqlite error while inserting new record (#232)

Just get your sources. And create messages. All works ok. So i think problem
on your server.


Reply to this email directly or view it on GitHub
#232 (comment) .

@rusmaxim
Copy link
Contributor

I think it may be useful

@qiangxue
Copy link
Member

Is the directory containing your sqlite file writable?

@philippfrenzel
Copy link
Contributor Author

Yes 777

Von meinem iPhone gesendet

Am 11.05.2013 um 14:01 schrieb Qiang Xue notifications@github.com:

Is the directory containing your sqlite file writable?


Reply to this email directly or view it on GitHub.

@cebe
Copy link
Member

cebe commented May 11, 2013

disk space problems? any special open_base_dir restrictions or other things active?

@cebe
Copy link
Member

cebe commented May 11, 2013

@philippfrenzel
Copy link
Contributor Author

thanks for the many answers and suggestions! The think is, that on my external webserver it works, but on my local machine it fails:( with yii 1.11 I have no problems!

The owner of the db-file is: staff

@philippfrenzel
Copy link
Contributor Author

For complete enviroment here the log enty while I try to insert:

2013/05/11 18:55:17 [::1] [error] [yii\db\Command::execute] SQLSTATE[HY000]: General error: 14 unable to open database file
Failed to execute SQL: INSERT INTO 'tbl_messages' ("reciever_id", "subject", "is_read", "creation_date", "sender_id") VALUES ('1', 'Test Test', '', '2013-05-11 18:55:17', '1')
2013/05/11 18:55:17 [::1] [error] [yii\db\Exception] exception 'yii\db\Exception' with message 'SQLSTATE[HY000]: General error: 14 unable to open database file' in /Users/philippfrenzel/Sites/pliq/frenzelgmbh/yii/vendor/yiisoft/yii2/yii/db/Command.php:307
Stack trace:
#0 /Users/philippfrenzel/Sites/pliq/frenzelgmbh/yii/vendor/yiisoft/yii2/yii/db/ActiveRecord.php(681): yii\db\Command->execute()
#1 /Users/philippfrenzel/Sites/pliq/frenzelgmbh/yii/vendor/yiisoft/yii2/yii/db/ActiveRecord.php(625): yii\db\ActiveRecord->insert(true, NULL)
#2 /Users/philippfrenzel/Sites/pliq/frenzelgmbh/app/controllers/MessagesController.php(50): yii\db\ActiveRecord->save()
#3 [internal function]: MessagesController->actionCreate()
#4 /Users/philippfrenzel/Sites/pliq/frenzelgmbh/yii/vendor/yiisoft/yii2/yii/base/InlineAction.php(47): call_user_func_array(Array, Array)
#5 /Users/philippfrenzel/Sites/pliq/frenzelgmbh/yii/vendor/yiisoft/yii2/yii/base/Controller.php(117): yii\base\InlineAction->runWithParams(Array)
#6 /Users/philippfrenzel/Sites/pliq/frenzelgmbh/yii/vendor/yiisoft/yii2/yii/base/Module.php(569): yii\base\Controller->runAction('create', Array)
#7 /Users/philippfrenzel/Sites/pliq/frenzelgmbh/yii/vendor/yiisoft/yii2/yii/web/Application.php(35): yii\base\Module->runAction('messages/create', Array)
#8 /Users/philippfrenzel/Sites/pliq/frenzelgmbh/yii/vendor/yiisoft/yii2/yii/base/Application.php(146): yii\web\Application->processRequest()
#9 /Users/philippfrenzel/Sites/pliq/frenzelgmbh/web/index.php(18): yii\base\Application->run()
#10 {main}
2013/05/11 18:55:17 [::1] [info] [application] $_GET = array (
'r' => 'messages/create',
)

$_POST = array (
'Messages' =>
array (
'reciever_id' => '1',
'subject' => 'Test Test',
'body' => 'Test Test ',
'is_read' => '',
),
)

$_COOKIE = array (
'__utma' => '111872281.460877435.1358881031.1358881031.1358881031.1',
'__utmz' => '111872281.1358881031.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)',
'PHPSESSID' => 'ddc935af191ef64db8c1106d72c48537',
)

$_SESSION = array (
'220a2205bf41869e8c5fdda55bb5a55d__id' => '2',
'220a2205bf41869e8c5fdda55bb5a55d__name' => 'admin',
'220a2205bf41869e8c5fdda55bb5a55drole' => '1',
'220a2205bf41869e8c5fdda55bb5a55d__states' =>
array (
'role' => true,
),
'search' => '',
'lists' =>
array (
0 => '9',
),
'country' => '',
'__flash' =>
array (
),
'__id' => '1',
'__captcha/site/captcha' => 'toxine',
'__captcha/site/captchacount' => 1,
)

$SERVER = array (
'UNIQUE_ID' => 'UY539cCoAAsAAU2jNpQAAAAH',
'HTTP_HOST' => 'localhost:8081',
'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:20.0) Gecko/20100101 Firefox/20.0',
'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,
/_;q=0.8',
'HTTP_ACCEPT_LANGUAGE' => 'de-de,de;q=0.8,en-us;q=0.5,en;q=0.3',
'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
'HTTP_REFERER' => 'http://localhost:8081/frenzelgmbh/web/index.php?r=messages/create',
'HTTP_COOKIE' => '__utma=111872281.460877435.1358881031.1358881031.1358881031.1; __utmz=111872281.1358881031.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); PHPSESSID=ddc935af191ef64db8c1106d72c48537',
'HTTP_CONNECTION' => 'keep-alive',
'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
'CONTENT_LENGTH' => '112',
'PATH' => '/usr/bin:/bin:/usr/sbin:/sbin',
'DYLD_LIBRARY_PATH' => '/Applications/XAMPP/xamppfiles/lib',
'SERVER_SIGNATURE' => '',
'SERVER_SOFTWARE' => 'Apache/2.4.3 (Unix) OpenSSL/1.0.1c PHP/5.4.7',
'SERVER_NAME' => 'localhost',
'SERVER_ADDR' => '::1',
'SERVER_PORT' => '8081',
'REMOTE_ADDR' => '::1',
'DOCUMENT_ROOT' => '/Users/philippfrenzel/Sites/pliq',
'REQUEST_SCHEME' => 'http',
'CONTEXT_PREFIX' => '',
'CONTEXT_DOCUMENT_ROOT' => '/Users/philippfrenzel/Sites/pliq',
'SERVER_ADMIN' => 'you@example.com',
'SCRIPT_FILENAME' => '/Users/philippfrenzel/Sites/pliq/frenzelgmbh/web/index.php',
'REMOTE_PORT' => '59558',
'GATEWAY_INTERFACE' => 'CGI/1.1',
'SERVER_PROTOCOL' => 'HTTP/1.1',
'REQUEST_METHOD' => 'POST',
'QUERY_STRING' => 'r=messages/create',
'REQUEST_URI' => '/frenzelgmbh/web/index.php?r=messages/create',
'SCRIPT_NAME' => '/frenzelgmbh/web/index.php',
'PHP_SELF' => '/frenzelgmbh/web/index.php',
'REQUEST_TIME_FLOAT' => 1368291317.51,
'REQUEST_TIME' => 1368291317,
'argv' =>
array (
0 => 'r=messages/create',
),
'argc' => 1,
)

@philippfrenzel
Copy link
Contributor Author

ok, finaly found another possible reason...
inside the textarea, i have a "wrong" id:

textarea id="messages-body" rows="10" name="Messages[body]"

@cebe
Copy link
Member

cebe commented May 11, 2013

So it works now? After you changed a text areas id?

@philippfrenzel
Copy link
Contributor Author

Ok, I'm still in "search" mode! And it's not the textareas id -> and although not the database access! I can easily read and write with other components...

I created a simple console controller thanks to @cebe ! and with this it's easy to create users or messages

complete project can be found in the repo and running sample is online under www.frenzel.net ...
I will dig into the blog2.0 from @netyum to see how he is writing (mysql) but should be the same?!

@philippfrenzel
Copy link
Contributor Author

I close it, as it works online without any problems... can't figure out the local problem:( but must be a fault of my configuration... if you don't agree, pls. reopen;)

@elyzov
Copy link

elyzov commented Jan 29, 2015

I had this problem too. You must set mode 777 on directory which contains sqlite database, and all will work.

@m0yellow
Copy link

m0yellow commented Jan 8, 2016

don't recommend chmod 777 ...
recommending changing the owner to the web server user, and restricting access to anybody else would be appropriate.

    chown -R <www-userorwhateveritiscalled> folder 
    chmod -R go-rwx folder
    chmod -R u+rwX folder

gives you
drwx------
on the folder
and
-rw-------
on the database.

@macall
Copy link

macall commented Jun 30, 2016

@elyzov THX a lotttttttt!!!!!!!!! That costs me lots of time to find the answer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:to be verified Needs to be reproduced and validated. type:bug Bug
Projects
None yet
Development

No branches or pull requests

7 participants