Drupal error and solution: Access denied for user in mysqli or mysql

I have been facing this peculiar problem in drupal. I was migrating a drupal site from one server to another and it stopped working, giving me the error ‘Access denied for user ‘some_user’@localhost (using password: YES)

It was strange since i had done everything correctly and from command line i could login into mysql server.

While i was browsing the file sites/default/settings.php my eye went into the following lines:

* Note that the $db_url variable gets parsed using PHP's built-in
* URL parser (i.e. using the "parse_url()" function) so make sure
* not to confuse the parser. If your username, password
* or database name contain characters used to delineate
* $db_url parts, you can escape them via URI hex encodings:
*   : = %3a   / = %2f   @ = %40
*   + = %2b   ( = %28   ) = %29
*   ? = %3f   = = %3d   & = %26

I was a victim of highly unpropable circumastances! lol My password contained the sequence ‘%40’ which was being considered as the escape of character ‘@’ , so my password was interpreted wrong!

I guess that this error had to do with the php version. So in my first server (Gentoo PHP 5.2.6-pl7-gentoo) there was no problem but in the second server (Debian – PHP 5.2.0-8+etch15) there was.

After i changed my password it connected successfully.

PS. It was over a year since i posted last time, so … hurray!

Rails select tag problem , not working , it doesn’t choose correct option in enum fields!

I have been searching for hours to solve a problem in one of my forms. One of my models has an enum field with some options. e.g. enum(‘a’, ‘b’, ‘c’)

When i edited an entry of this model class i noticed that my listbox didn’t have the correct option chosen.


<%=  select('myobject', 'type', ["a","b","c"]) %>

didn’t work

<%=  select('myobject', 'type', ["a","b","c"], {:selected => @myobject.type}) %>

didn’t work either

After many hours and having to develop a helper select function of my own, i found out that this works:

<%=  select('myobject', 'type', ["a","b","c"], {:selected => @myobject.type.to_s}) %>

For some reason rails doesn’t recognize the enum field’s value as a string and the comparisons don’t take place correctly. After casting it to string it worked 🙂

That’s all for now. Bye.

WordPress – tinyMCE is not defined error, a solution

After spending lots of time for this tinyMCE bug and trying many solutions i found out there, i finally got it working. It seems to be a problem with gzipping tinyMCE code and some servers hosting wordpress.

I solved my problem on this server by editing file : wp-includes\js\tinymce\tiny_mce_config.php , line 208 in wordpress 2.5.1

Just change:

 'compress' => true


'compress' => false

Bugfixing for gWidgets for use with prototype

gWidgets is a really nice library of widgets. I have been using it for some time with success, gTabs especially.

A friend of mine ktolis who has been using the new Safari browser and Firefox 3 beta told me that the tabs wouldn’t appear because of javascript errors.

It has been concluded now that the errors were caused by 2 factors Firefox3 and Safari (that both implement HTML 5) and the fact i have been using latest prototype library

Javascript errors appeared in lines 232, 299, 448 and 528 of gwidgets.js saying that ‘each is not a function’.

Then i found this post: document.getElementsByClassName

According to the above post in new browsers, implementing html 5, ‘each’ is not implemented on the array returned by document.getElementsByClassName() because getElementsByClassName is implemented by the browser and not prototype any more(for prototype 1.6 and newer that is). So i simply replaced document.getElementsByClassName(blahblah).each occurencies in gwidgets.js with for loops to iterate the returned array. The errors stoped after this.

Also i would like to mention another fix concerning a css problem with gTabs , where if the text inside the tab is quite large the tab doesn’t resize. If you comment line 95 in gwidgets.css the tabs can be resized to fit their content.


Firebolt 0.3 released

Well at last firebolt 0.3 is released. If you are into C++ , sockets and of course protocols you have to take a look at it.

Firebolt is a network protocol oriented library. It’s not another socket library, it offers higher level services to the developer. You can structure your protocol in the form of states and the transitions between those states with the use of your custom events. Thus you no longer need to worry about what data you just received from a socket and whether or not those data are expected in the current state of your network code. That sort of validation is all performed by firebolt!


How to generate a makefile from your Visual studio .Net code

I have found a nice tool called cmake which can create a makefile for you given the source code directory of your project. It seems to be quite configurable. So if you were always troubled about how are you going to create the makefile for linux, you don’t have to worry any more.

This tool can also go the other way around. Given the source code it can create the solution project (*.sln) for your visual studio .net environment.

I will try it on some of my projects and see how it goes.

Keep coding 🙂

Easy installer in no time

I have been trying recently to create a simple installer using Visual Studio .Net 7.1 setup project.

All i needed my installer to do was to run a simple program from a shell. I didn’t need any program folders, registry keys and of course no entry into the Add Remove programs. Such thing is simply impossible! I ended up creating a dummy installer class, to use it as a custom action during install. What i did in that installer class was simply to throw an InstallException so that the installation rolls back and thus not getting the entry of my installation into Add Remove programs.

Next problem was that i didn’t want the user to know about this intended failure. I tried to play with the installers gui but things there are sort of ‘hardcoded’ so you can’t change the messages of your installer’s Finish screen. One sollution that came to me was to erase all dialogs (since i required no input from the user during installation).

All the above was quite a mess for a simple almost do-nothing installer. Among other things, due to the use of the installer class i created, the user of the installer was also required to have the .Net Framework 1.1 on his system!!!

Finally i used Inno Setup and everything was ready in minutes. In specific the functionality in wanted (no entry in Add Remove programs) was simply one checkbox.
What a mess…

Check for administrator rights in VB .Net 2003

Here we go again with another usefull piece of code. The following code is for determining if the user that runs your application belongs to a specific group. In the following example i check if the user belongs to group ‘Administrators’

The following code applies in Namespace System.Security.Principal

Dim user As WindowsIdentity
user = WindowsIdentity.GetCurrent()
Dim principal As New WindowsPrincipal(user)
If Not principal.IsInRole(“BUILTIN\Administrators”)
MsgBox(“Sorry you have to be an administrator”)
End If

Ok that’s it. In VB .Net 2005 there is the My.User object which provides such functionality, so there is no need to do the above.

Happy coding 🙂

How to add code into Swig wrapper for C++ class constructor, targeting Ruby

Ok i know it’s a big title … but it describes the problem.

Lets say that you have a C++ class and you wrap it using swig. Now you decide to inject some code of your own into the constructor wrapper. If you try defining a typemap(out) you will not succeed. Instead the way to do it is this:

%module test


Β #include “MyClass.h”



%feature(“ref”) MyClass ” Here between the quotes add your code ”


%include “MyClass.h”


Well that’s it. Let me note, in case you are not aware, that the above code should go inside the *.i file that will be parsed by swig. You have now managed adding extra code into the _wrap_new_MyClass function that wraps the costructor of your class. Keep in mind that the above solution goes if you are targeting Ruby. Perhaps for other scripting languages you can add code into contructor wrapper function using %typemap(out) MyClass*, but that doesn’t work for Ruby. The above case is valid for swigwin-1.3.27 that i use currently.

Keep coding.


How to use LoadResData in VB .Net

If you need badly to use LoadResData in .Net VB you will have to use the VisualBasic.Compatibility namespace. This also applies to otherΒ VB6 functions that areΒ notΒ supported in .Net VB any more.

First of all right clickΒ onΒ your project in the solution explorer pane. Choose add reference and in the tab named .NET choose the ‘Microsoft Visual Basic .Net Compatibility’ and press select button. Then press ok.

Now write Microsoft.VisualBasic.Compatibility.VB6.LoadResData (…) and do whatever you want. If you don’t want to constantly write all the above extremely long line you can go to your project’s properties, select Common Properties->imports on the left window and add the namespace Microsoft.VisualBasic.Compatibility.VB6 into your project. After that you can directly write LoadResData(…)