Month: July 2010

How to check if a MySQL database connection is successful in PHP?

If you have mysqli extension installed with PHP and you use it to perform database operations, after you have tried to connect to MySQL by: $conn = new mysqli(‘localhost’, ‘db_user’, ‘db_pwd’, ‘db_name’); You can then check if the connection is successful by: if ($conn -> connect_errno) { // failure } else { // success } …

How to check if a MySQL database connection is successful in PHP? Read More »

MySQL: Check if a table exists

When I was creating an installation script, I needed to check if a table exists to make sure the installation had not been performed yet. How did I do that? I use this simple query to get whether a table exists in the specified database: SELECT table_name FROM information_schema.tables WHERE table_schema = ‘db_name’ AND table_name …

MySQL: Check if a table exists Read More »

How to include a JavaScript file inside a JavaScript file?

This is a pretty odd question to ask in the first place if you have been using JavaScript for a while. JavaScript files are called from HTML web pages who need them to manipulate the HTML elements so that the users have extraordinary interactive experience. You can’t include a JavaScript file inside another JavaScript file …

How to include a JavaScript file inside a JavaScript file? Read More »

JavaScript: How to set focus to form elements?

Normally, when users click on any label tag with the cursor, the corresponding input field will be focused ready for input or selection. Therefore, you can always achieve the focus effect by this native function of HTML’s. Otherwise, you’d need a small dime of JavaScript to set focus to any form element on the fly …

JavaScript: How to set focus to form elements? Read More »

PHP: Delay Function that Halt Code Execution Temporarily and Then Resume It

Sometimes you need to temporarily halt the code execution of your PHP script for certain seconds and then automatically resume it. For example, some mail delivery servers have the restriction that you have to wait a certain interval such as 12 seconds before sending another email. You can tell your PHP script to stop for …

PHP: Delay Function that Halt Code Execution Temporarily and Then Resume It Read More »

Way to go PayPal! – Fraudulent Chargeback Successfully Resolved in Merchant’s Favor

I made a sale months ago when someone purchased a few website scripts for over $1,500. A few days after the transaction he fired a chargeback dispute. I thought, well ok, I’m puked. I almost gave in. But then I thought I couldn’t let him win this easily. So I provided everything I can with …

Way to go PayPal! – Fraudulent Chargeback Successfully Resolved in Merchant’s Favor Read More »

PHP and JavaScript Variable / Value Transfer / Exchange: How to pass variable values from PHP to JavaScript or JavaScript to PHP?

This is a rather common problem for novice web developers. While it may seem at first glance that it’s easy for PHP and JavaScript to communicate with each other, but they actually cannot interact with each other directly. They are very different technologies built for distinct purposes. How to transfer or pass variable values from …

PHP and JavaScript Variable / Value Transfer / Exchange: How to pass variable values from PHP to JavaScript or JavaScript to PHP? Read More »

How to execute / run PHP code inside JavaScript files?

Static files of JavaScript would survive most applications but sometimes the ability to include PHP code inside JavaScript scripts and generate the content of the script files on the fly by PHP is a better option. How does one do that? The simplest solution is to just include PHP code inside the <script></script> section of …

How to execute / run PHP code inside JavaScript files? Read More »

MySQL logic operators: How to use AND, OR together in WHERE clauses in one query?

AND and OR are common logic operators across all programming languages and in MySQL, they mean the same thing. A statement (a.k.a, a condition in any WHERE clauses such as id > 100) can be either true or false. A group / combination of statements can be true or false, depending on their own values …

MySQL logic operators: How to use AND, OR together in WHERE clauses in one query? Read More »

This payment cannot be completed and your account has not been charged. Please contact your merchant for more information.

Very rarely you may encounter this error after you have clicked the “Pay Now” button on PayPal to send payment to someone / merchant in purchase of something: This payment cannot be completed and your account has not been charged.  Please contact your merchant for more information. At first, I blamed my website payment integration …

This payment cannot be completed and your account has not been charged. Please contact your merchant for more information. Read More »

Prova.fm, the Design Contests Platform – From Outsource to Crowdsource

When you need something done, design contests are a much better way to get the quality and diversity you need than traditional design outsourcing because you get multiple submissions from various designers who are after the bounty prize. It may be a little more expensive than when you hire just one designer, but the quality …

Prova.fm, the Design Contests Platform – From Outsource to Crowdsource Read More »

Best and Newest HTML5 Books (and Some CSS3 Books)

HTML5 and CSS3 are becoming a reality. To be better prepared and armed with the latest technologies of the web so that we stay on the cutting edge when creating stuff, I have found some of the best book titles at Amazon about HTML 5 and CSS 3. Note that several of these books have …

Best and Newest HTML5 Books (and Some CSS3 Books) Read More »

How to delete a Skype account so that it doesn’t appear in search?

Several of the Google results for ‘how to delete Skype account’ suggest that you can’t literally delete any Skype account once created. However it really bothers me that more than one account under one email address would definitely confuse people who have searched for you and are trying to figure out which one is the …

How to delete a Skype account so that it doesn’t appear in search? Read More »

How to bring down / optimize memory usage in your unmanaged Linux VPS box and avoid OOM (Out Of Memory) errors?

The other day I was very upset about some extraordinary down times of my unmanaged VPS box at Linode. As it’s unmanaged, support staff at Linode are not responsible for the failures. I contacted them and they told me it’s OOM (Out Of Memory), pointing me to the right documentation to figure out how to …

How to bring down / optimize memory usage in your unmanaged Linux VPS box and avoid OOM (Out Of Memory) errors? Read More »