Have you ever tried to use SELECT…INTO OUTFILE in MySQL and come across the following error?
"Can’t create/write to file ‘/path/to/folder/filename’ (Errcode: 2)"
I was having this problem the other day and, after checking that file permissions weren’t the cause of the problem, I came across the following post on the MySQL forums:
"The problem was not in MySQL but in AppArmor on Ubuntu. I had to add the directories I wanted to write into to my /etc/apparmor.d/usr.sbin.mysqld and restart apparmor.d."
So, one sudo vim /etc/apparmor.d/usr.sbin.mysqld later and I’d added the path/to/folder I needed to be able to write to (not forgetting to add the trailing comma ‘,’ to the end of the line, which is always required, even for the last line).
All that was left to do was to restart AppArmor with:
$ sudo /etc/init.d/apparmor restart
After that, SELECT…INTO OUTFILE worked like a charm
Posted in
web at August 24th, 2010.
No Comments.
Recently I made a few amends to some Greasemonkey scripts I wrote a while back and, since I’ve been using git quite a bit recently, it made sense to me to move my Greasemonkey scripts onto GitHub.
So I did
And here they are:
Posted in
javascript,
web at August 18th, 2010.
No Comments.
Being fairly new to Drupal, I was interested to know whether it had anything built in that let you know, or detect, when a user was logging in for the first time e.g. to show them a welcome message.
As far as I know, there’s no method in the API to detect this. However, after checking the global $user object's properties to see what we had to play with, it turns out it wasn't all that tricky:
- the
$global user contains 3 timestamp properties: created, access and login
- when a user logs in for the first time, all 3 of these timestamps are equal
This means we can check whether a user is logging in for the first time with something like this:
function is_first_time_login($user) {
return ($user->created == $user->login) &&
($user->login == $user->access);
}
Now we can call that function where we need to in our elsewhere in our code. For example:
function foo() {
global $user;
...
if (is_first_time_login($user)) {
drupal_set_message(WELCOME_MSG);
}
...
}
So far, this approach seems to be working quite well
Posted in
web at August 5th, 2010.
2 Comments.