Thursday, October 9, 2014

Turn off PHP magic quotes on shared hosting

I have a simple html form containing textarea and submit button. When I submit the form, PHP automatically escape all single quote. The problem happens only on shared hosting.

This problem caused by PHP's magic quotes. It's automatically turn on in my shared hosting.
So, how to turn it off?

Firstly, open the File Manager on your web hosting, and go to the root folder.
In my case, I go to the root folder for the subdomain.
Example: if the subdomain is guitar.example.com, then I go to public_html/chord folder.

Now, let's create "php.ini" file in this folder, then add this line
magic_quotes_gpc = Off

Then saves the file. That's all, magic quotes is off.

By the way, what is gpc? It stands for Get Post Cookie. So, it turns off magic quotes for Get, Post, Cookie variables.

Wednesday, September 17, 2014

Changing default timezone in WAMP

I use WampServer on Windows 7. I tried to display the default time using PHP, but the wrong time was displayed.

Well, the default timezone was incorrect. How to change it?
First, click the WAMP icon, then go to PHP, then open php.ini.

Now, search for "date.timezone", then change the value from UTC to anything you want.
In my case, I changed it to Australia/Sydney.

You can find the list of supported timezones here:





Wednesday, February 26, 2014

Install ruby's mysql gem on Windows 7

I have mysql database on my computer. I would like to use Ruby to access it.

First step is to install mysql gem. Run this at command prompt:
gem install mysql

Next step is to download the libmysql.dll
Here's the link to download the dll
http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick
Extract the downloaded file, and go to the 'lib' directory and copy 'libmysql.dll'.

Now go to your ruby installation folder, open the "bin" folder, then paste the "libmysql.dll".

That's all.

How to test it? Create a ruby file, and type
require 'mysql'

Then run it. You won't see any error if the installation was successful.

Sunday, February 23, 2014

Install Chrome for all users in Windows 7

I created a new user account in Windows 7. When I logged in using the new account, I could not find Chrome browser.

How to solve this problem?

  1. Log in using administrator account
  2. Uninstall Chrome (https://support.google.com/chrome/answer/95319?hl=en)
  3. Download this alternate Chrome installer: https://www.google.com/intl/en_uk/chrome/browser/index.html?system=true&standalone=1#eula
  4. Done
The alternate Chrome version will install Chrome for all user accounts (https://support.google.com/chrome/answer/118663?hl=en).

However, there's a problem with the Chrome for administrative account. There's an error saying "Your profile cannot be used because it is from newer version of Google Chrome".

To fix it, go to this folder:
C:\Users\YOURUSERNAME\AppData\Local\Google\Chrome\User Data\Default

(Note: if you can't see the AppData folder, you have to activate the "Show hidden files" option in the folder option)

Then delete the "Web data" file.

Then I tried to open the Chrome but nothing happened.
So, I log out from Windows, then log in again.
Now everything's allright.

Wednesday, February 19, 2014

Can't start CyberLink YouCam on Windows 7

CyberLink YouCam 3 can't be open on my Windows 7 laptop. There's nothing happen when I tried to open it.

I found 2 solutions for this problem.

Solution 1: Run it as administrator. Just right click on the program link, then choose "Run as administrator".

Solution 2: Right click on the program link, then choose "Troubleshoot compatibility".
Choose "Try recommended settings", then choose "Start the program". If YouCam is started, then you can just click "Next" and choose "Yes, save these settings for this program".


Thursday, January 23, 2014

No sound in TuxGuitar (Ubuntu 13.10)

There was no sound when I played music in TuxGuitar.
How to fix it? Firstly, install Timidity (see my previous post).

Then open "Tools > Settings" or F7 in TuxGuitar. Go to "Sound", and change the Midi PORT to one of the timidity port.


That's all.

Play MIDI on Ubuntu 13.10

By default, you can't play MIDI on Ubuntu 13.10.
You have to install MIDI player such as Timidity.

I used Ubuntu Software Centre to install Timidity. Just search for 'timidity', and it will show up as 'Software sound renderer (MIDI sequencer, MOD player)'. I also chose 'fluid-soundfont-gm' in the optional add-ons.

We have to use command line to open Timidity.
timidity yourmidifile.mid
If you want to use GUI:
timidity -ia

Wednesday, January 22, 2014

Create cPanel for subdomain

Let's say you have a domain called "example.com". You want to create a subdomain "guitar.example.com", and you want the subdomain to have its own cPanel.

Basically there are 2 ways to create subdomain:
1. Using cPanel.
2. Using Web Host Manager.

What's the difference?
When creating subdomain using cPanel, you will not get a new cPanel account.
So, to upload subdomain's files, you have to login to cPanel using the parent domain account. This is problematic if you want to create subdomain for your customer.

However, if you create subdomain using Web Host Manager, you will get a new cPanel account. So, you will only be able to access the subdomain's files when you login to the subdomain cPanel.

Sunday, January 19, 2014

Fixing 'page not found' when using permalink in WordPress (Ubuntu 13.10)

I tried to use permalink in WordPress. WordPress automatically created .htaccess file.

However, when I opened the page, there was 'page not found' error. A few things that I did to fix this problem:

Firstly, run
sudo a2enmod rewrite
Then I restarted the apache
sudo service apache2 restart
Well, I still got the 'page not found' error.

Then, I edited the apache2.conf file. It's located in /etc/apache2/
gksudo gedit apache2.conf
Search for this part on the file
<Directory /var/www/>
 Options Indexes FollowSymLinks
 AllowOverride None
 Require all granted
</Directory>
I changed the AllowOverride from None to All.
<Directory /var/www/>
 Options Indexes FollowSymLinks
 AllowOverride All
 Require all granted
</Directory>
Now, let's restart the apache
sudo service apache2 restart
Now I can open the page with permalink.
Done.

References:
http://www.networkinghowtos.com/howto/enable-apache-rewrite-module-on-ubuntu-13-04/
http://stackoverflow.com/questions/19518907/virtual-host-on-ubuntu-13-10-and-apache-2-4-6

Install TrueCrypt on Ubuntu 13.10

Firstly, go to http://www.truecrypt.org/downloads to download the file.
I chose the "Standard - 32bit".

Go to the download folder, right click the file,  then choose "Extract Here".

Now let's open the terminal. Go to the download folder and run the installation file.
./truecrypt-7.1a-setup-x86
You will see the installation program. Then just click "Install TrueCrypt".

You will also see the command to uninstall TrueCrypt.

The installation is finished.

Now let's run TrueCrypt. Go to the Unity Dash and search for "truecrypt".
Done.

Friday, January 17, 2014

Remote Desktop to Windows from Ubuntu 13.10

We can use Remmina Remote Desktop Client to connect to Windows remotely.
Remmina is installed by default on Ubuntu 13.10.

To open Remmina, just use Unity Dash and search for 'remmina'.

To create a new connection, just click the 'Create a new remote desktop file' (It's the second button from the left)


Then enter your connection details and click 'Connect'.

Reference;
http://www.7tutorials.com/connecting-windows-remote-desktop-ubuntu

Configure PPTP client on Ubuntu 13.10


Firstly, click on Network Manager icon, then choose "VPN Connections > Configure VPN".

Click 'Add' button, then choose PPTP from the drop down list, then click 'Create'.

Enter the connection details, then click 'Save'. 




Now let's test the connection.
Click the Network Manager icon, then 'VPN Connections', and choose your connection.


You will see a 'VPN Login Message'.


Done.


Install Photoscape on Ubuntu 13.10

Firstly, we have to install the latest wine.
Run this command in terminal
sudo add-apt-repository ppa:ubuntu-wine/ppa
sudo apt-get update
sudo apt-get install wine1.7
Download the Photoscape. Open the download folder and right click on the Photoscape file, choose 'Open With Wine Windows Program Loader'.
Once we've finished the installation, we can open Photoscape from Unity Dash.


That's all.

Reference:
http://www.winehq.org/download/ubuntu

Monday, January 13, 2014

Yii migration safeUp() is not working

I tried to create a table using the safeUp() function. Here's the content of the migration file
class m140113_223038_create_test_tables extends CDbMigration
{
 public function up()
 {
 }

 public function down()
 {
 }

 public function safeUp()
 {
  $this->createTable('tbl_test',array(
   'id'=>'pk',
   'name'=>'string NOT NULL',
   ),'ENGINE=InnoDB');
 }

 public function safeDown()
 {
  $this->dropTable('tbl_test');
 }
}
However, it won't create a new table. The solution is actually very simple. If we want to use safeUp() function, we have to make sure that there's no up() function in the code. So, we have to remove both up() and down() function.
class m140113_223038_create_test_tables extends CDbMigration
{
 public function safeUp()
 {
  $this->createTable('tbl_test',array(
   'id'=>'pk',
   'name'=>'string NOT NULL',
   ),'ENGINE=InnoDB');
 }

 public function safeDown()
 {
  $this->dropTable('tbl_test');
 }
}
Reference:
http://stackoverflow.com/questions/18126773/yii-framework-yic-migrate-command-doesnt-work

Wednesday, January 8, 2014

Yii shell is not working

I tried to run yii shell on Ubuntu 13.10 using this command:
protected/yiic shell

But it's not working. A long lines of HTML output was displayed on screen.

I found 2 solutions on the web:
1st: use this command instead:
protected/yiic shell protected/config/main.php

2nd: modify protected/config/main.php, and add this line at the top:
date_default_timezone_set('UTC')

References:
http://stackoverflow.com/questions/11792981/yii-command-tool-not-work
http://stackoverflow.com/questions/7841523/yiic-command-line-tool-outputting-code-instead-of-opening-shell

Sunday, January 5, 2014

Install phpmyadmin on Ubuntu 13.10

To install phpmyadmin, run
sudo apt-get install phpmyadmin
When I open http://localhost/phpmyadmin, it says ".../phpmyadmin/ was not found on this server".

How to fix it?
Firstly, open /etc/apache2/apache2.conf
You can open it by pressing Alt+F2, then type
gksudo gedit /etc/apache2/apache2.conf
Note: if gksudo is not installed, you can install it using "sudo apt-get install gksu".

Then go to the end of the file and type
Include /etc/phpmyadmin/apache.conf
Save the file, then restart the apache using this command
sudo /etc/init.d/apache2 restart
Done.

Install LAMP on Ubuntu 13.10

Open the terminal, then run
sudo apt-get install lamp-server^
^ sign is a Tasksel command (https://help.ubuntu.com/community/Tasksel)

Now, let's make a new php file to test.
Firstly, I'm going to open a text editor called gedit as a root user.

Press Alt + F2, then run
gksudo gedit
Note: if gksudo is not installed, you can install it using
sudo apt-get install gksu
Then type this php code
<?php
phpinfo();
?>
And save it in /var/www/ folder. I use "phpinfo.php" as the file name.
Now, open it in web browser: http:/localhost/phpinfo.php
You should be able to see the output of phpinfo().
LAMP server installation is done.
References:
Source: http://gregrickaby.com/how-to-install-lamp-on-ubuntu/