2012年12月4日 星期二

[RESOLVED] Warning: SimpleXMLElement::asXML(): string is not in UTF-8 in C:\XXXX

I've tried to export an XML file from php but failed to generate with Chinese Character. 

<?php
    $xml = new SimpleXMLElement('<xml/>');

    for ($i = 1; $i <= 10; ++$i) {
        $invoice = $xml->addChild('invoice');
        $invoice->addChild('customer', "客戶名稱");
        $invoice->addChild('invoiceNo', "invoiceNo $i");
    }

    Header('Content-type: text/xml');
    print($xml->asXML());
?>

The following error will be shown.
Warning</b>: SimpleXMLElement::asXML(): string is not in UTF-8 in C:\XXXX
Solution:
The error is caused by the incorrect encoding in the file. You might use your editor to open the file and change the encoding to UTF-8 for the resolution.


2012年9月28日 星期五

Create your own shorten links

phurls

This open source helps you to manage the shorten URL of your website.
Such as:
http://yp-php-drupal.blogspot.hk/
---> http://<yourdomain>/php




2012年9月23日 星期日

[RESOLVED] Chrome: Error 312 (net::ERR_UNSAFE_PORT): Unknown error

Chrome Browser shows the following error when trying to access some unusual ports.

Error 312 (net::ERR_UNSAFE_PORT): Unknown error


1. Close all your Chrome
2. Right click to the "Chrome" icon in desktop, add parameter  --explicitly-allowed-ports=110

3. Start the Chrome and try the ports again.





2012年9月21日 星期五

[RESOLVED] Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Unable to Connect to ssl://www.google.com:443

Today I tried to move the application to a new machine with XAMPP, the program returns the following fatal error.

Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Unable to Connect to ssl://www.google.com:443. Error #1607254839: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?' in C:\XXXX

The PHP program would connect to the Google Calendar by using Zend Framework, which requires SSL enabled in the PHP setting.

Steps to enable SSL socket in XAMPP

1. Go to XAMPP Control Panel and stop the Apache

2. Click the "Config" button under Apache and edit php.ini

3. Enable the OpenSSL by removing the ; at the beginning of the line

extension=php_openssl.dll





4. Save and restart Apache

2012年4月13日 星期五

[Info] logout link in Drupal

The user logout link is accessible by the following URL:
http://example.com/user/logout

2012年3月22日 星期四

[SOLVED] Drupal: Move Site and results in 404 Error after login

Tried to move a development environment to another environment, by copying the files in the Drupal root directory , database, and then restored in another server.

Everything works well in the landing page. But returns an 404 page error when accessing the other pages. (such as login, go to the node content, etc..)

To resolve the problem, we have to the following things before exporting the db to the new site:
i. Clear the caches
ii. Disable the clean URLs feature

 



 

System works back to normal after doing the above steps.!

2012年3月20日 星期二

[How-to] Add Virtual Host using different port in apache

This article teaches you how to create multiple websites in an apache server by using different port.
In this example, we use port 80 and 90.

1. Update /etc/apache2/ports.conf
Add the following lines in the file
NameVirtualHost *:80
Listen 80  
NameVirtualHost *:90
Listen 90

2. Update /etc/apache2/sites-available/default
Copy and paste the <VirtualHost *:80> content and make changes as follow


<VirtualHost *:80>
   ...
</VirtualHost>
<VirtualHost *:90>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www_anothersite
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www
_anothersite/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>


3. Create the corresponding folder for the new website (port 90)
mkdir /var/www_anothersite

4. Done and test

2012年3月19日 星期一

2012年3月18日 星期日

[How-to] Install FileZilla in Ubuntu using command

This article teaches you how to install SFTP on Ubuntu.

1. Install Open SSH
Command: sudo apt-get install openssh-server openssh-client

2. Install FileZilla
Command: sudo apt-get install filezilla

After the installation, you can connect to your Ubuntu server via the sFTP.




2012年3月17日 星期六

[SOLVED] Failed to connect to MySQL at :3306 with user root

This article teaches you how to make a remote connection to MySQL server via the MySQL Workbench.

By the default installation, MySQL does not allow remote access to the server. When you tried to directly connect to the server, you will find the following error:

Failed to connect to MySQL at <mysql server ip address>:3306 with user root


Found and tried solutions on how to enables the MySQL connection, but the result is not good. System would returns an error of

ERROR 2002 (HY000) can't connect to local MySQL server through socket '/var/run/mysqld/mysql.sock' (2)


Solution
As the enablement of remote access may caused potential issue, I go back to MySQL workbench to find any hint for the solution.

At this moment, I found that the remote connection to MySQL server could be achieved by Connection Method "Standard TCP/IP over SSH".


After inputting the corresponding information and click "Test connection", successful result returns and can connect to the remote MySQL server.


[How-to] Uninstall MySQL server in Ubuntu

It can be achieved by the following command.




sudo apt-get remove --purge mysql-server

2012年3月15日 星期四

[How-to] Hide Text format selection in comment area


This article teaches you how to hide the Text format area selection on "Comment" field in Drupal 7.
It also applies to other Filtered HTML textarea in Drupal 7.

Solution:
Add the following style to the css file

.filter-wrapper {    display: none; }


2012年3月7日 星期三

Better Offer on GoDaddy, no need coupon


This is a small trick on GoDaddy.com.
The above special offer could be obtained by add the domain, but not to paid. 
After several rounds of back and fore, a special offer will be shown in the web site.

Known special offer:
i. Special Offer: New .com domain registration: 7.99 per year
By clicking domain registration but not to paid, cancel it, back and fore several times
- can be 1 year to 10 years domain registration
- 1 year is not recommended, better to click the ads with offers $5.99 for 1 year
Tackle the Web with up to 5 new .COMs, $5.99 for the 1st year!


ii.  Special Offer:  Free upgrade to Ultimate plan by Deluxe plan offer
Click web hosting Ultimate plan but not to paid, cancel it, back and fore several times

Reference:
GoDaddy.com


2012年3月2日 星期五

[SOLVED]: Fatal error: Allowed memory size of 33554432 bytes exhausted (Drupal 7 on XAMPP)

In XAMPP, the memory limit for php is set 32MB by default. It would cause a Fatal error in Drupal that runs on XAMPP for the development.

Example
Fatal error: Allowed memory size of 33554432 bytes exhausted
D:\xampp\htdocs\sites\all\modules\ctools\plugins\export_ui\ctools_export_ui.php


Solution
We can resolve the problem by increasing the memory limit in the php.ini file.

Step 1. Locate the php.ini file in XAMPP
e.g. D:\xampp\php\php.ini
 

Step 2. Search for the keyword: memory_limit and replace it in the following way


max_execution_time = 60     ; Maximum execution time of each script, in seconds
max_input_time = 60    ; Maximum amount of time each script may spend parsing request data
memory_limit = 32M 256M     ; Maximum amount of memory a script may consume (16MB)




 Step 3. Restart the Apache via the Control Panel XAMPP


Step 4. Done and check by the phpinfo.php











2012年2月19日 星期日

[SOLVED]: Drupal: Notice: Undefined variable: hide_site_name in include()

The error message below may be shown after changing the theme in Drupal 7.

  • Notice: Undefined variable: hide_site_name in include() (line 98 of /home/XXXX/public_html/XXXX/sites/all/themes/XXXX/templates/page.tpl.php).
  • Notice: Undefined variable: hide_site_name in include() (line 108 of/home/XXXX/public_html/XXXX/sites/all/themes/XXXX/templates/page.tpl.php).

The problem is due to the cache in Drupal, to resolve:

Step 1. Go to Configuration

Step 2. Go to Development -> Performance

Step 3. Clear Cache -> Clear all caches

Step 4. The error message is gone!