Result with unreadable code from DB query in PHP

December 19, 2011 Leave a comment

Problem:
Print the result from DB query and got unreadable code

Solution:
In phpMyAdmin, check the table field of Collation, if value is utf8_general_ci
Then in PHP code, add mysql_query(‘SET NAMES utf8’);

Categories: PHP

Create a shortcut for uploading FLV file to streaming server

December 14, 2011 Leave a comment

Problem
All FLV file should be uploaded to /usr/local/WowzaMediaServer/content, However we can’t directly upload file to non-web-directory in Drupal back-end.

Try
use command of “ln” – not work
ln -s /usr/local/WowzaMediaServer/content /srv/www/htdocs/sites/default/files/videos/upload_
flash_video

Solution
use command of “mount” – work
mount –bind /usr/local/WowzaMediaServer/content /srv/www/htdocs/sites/default/files/videos/upload_
flash_video

Categories: Linux

Eclipse word wrap plugin

December 12, 2011 Leave a comment
Categories: Eclipse

MySQL – Replace space in field’s data

December 8, 2011 Leave a comment

DSC_8728 retouch.jpg
DSC_8730 retouch.jpg
DSC_8744 retouch.jpg

Problem:
In my table “files”, it have some field’s data that contain a space.

Solution:
Use SQL replace()
REPLACE(field, from_str, to_str)

UPDATE bps2_files
SET filename = REPLACE(filename, ‘ ‘, ”)
WHERE `filename` LIKE ‘% retouch.jpg%’

Result:
DSC_8728retouch.jpg
DSC_8730retouch.jpg
DSC_8744retouch.jpg

Categories: MySQL

Check is there any network connection

December 2, 2011 Leave a comment

1. Sometime when you want to test is there any network connection
2. Press Ctrl + Alt + Delete
3. Go to the tab network
4, You will see the line moving at the diagram

Categories: Windows

Check which IP has been accessing by current webpage

December 2, 2011 Leave a comment

When testing some program on a PC that cannot access internet

i.e. Video Player

1. We may wait a moment for to see the video player appear
2. This is because the player accessing the internet, so we need to wait for time out
3. To test which IP has been accessed by this player, we can follow the step below:
– Windows Start > cmd
– netstat -n > c:\port.txt
– open the text file, check the result accordingly

*Reminder: Try to clear all connection first, that mean there are none of internet IP appear on the text file, then access the webpage, after that execute the command immediately. Finally, you may see some internet IP on the text file.

Categories: Windows

Drupal 6 – Issue of “The requested page could not be found”

November 25, 2011 Leave a comment

If you got the error message “The requested page could not be found”, it may because you haven’t set the alias for related page.

Solution:

1. Go to /admin/content/node
2. Edit the node(i.e. content type of “page”) related to the page having the error message
3. Set the alias, i.e. video for the page http://example.com/video
4. Save the node
5. View the page to see the result

Categories: Drupal

Convert a string to from UTF-8 to HTML entity in PHP

November 18, 2011 Leave a comment

<?php
$str = mb_convert_encoding("香港", 'HTML-ENTITIES', 'UTF-8'); // 香港
echo $str;

Reference: http://stackoverflow.com/questions/8162085/converting-a-javascript-function-to-a-php-functionused-to-convert-string-to-htm

Categories: PHP

Compare a column itself to check whether it have duplicated value

November 17, 2011 Leave a comment

Quick formatting:

  1. Select one or more cells in a range, table, or PivotTable report.
  2. On the Home tab, in the Style group, click the arrow next to Conditional Formatting, and then click Highlight Cells Rules.
  3. Select Duplicate Values.
  4. Select/Enter the values that you want to use, and then press ok.

Reference: http://stackoverflow.com/questions/8160903/compare-a-column-itself-to-check-whether-it-have-duplicated-value-in-excel

Categories: Excel

Create an UiImage with an URL in Objective-c

October 4, 2011 Leave a comment
NSURL *imageURL = [NSURL URLWithString:@"http://example.com/demo.jpg"];
NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
UIImage *image = [UIImage imageWithData:imageData];

Reference: http://stackoverflow.com/questions/7694215/create-a-uiimage-with-an-url-in-ios

Categories: Objective-c