Programming Tips & Insights

Top 25 Most Dangerous Web Programming Errors, Loopholes and Bad Habits

As Web becomes one of the most fundamental means of communication and information delivery nowadays, and as its usage reaches population level in regards to that when the televisions prevailed, the protection of it has never been so critical. SANS institute in association with US government and various other weighty contributors, most of whom IT …

Top 25 Most Dangerous Web Programming Errors, Loopholes and Bad Habits Read More »

Create SQL Auto Increment Column (ID: Primary Key) in Table

With database development, a perfect data structure paradigm is that data records should all be uniquely distinguishable from each other. Therefore when you are designing and creating data fields or columns for an entity, you must always have an identifying column or field for each and every of the records stored in a table, enabling …

Create SQL Auto Increment Column (ID: Primary Key) in Table Read More »

PHP: File Upload Script (HTML Form + PHP Handler Class)

It’s sometimes cumbersome to handle uploaded files — checking if it is really uploaded, moving and renaming. Why not writing all these chores into a class and make our own file upload script? First we are going to create a simple class to handle uploaded files and move them to some place we designate for …

PHP: File Upload Script (HTML Form + PHP Handler Class) Read More »

PHP: Resize Image and Store to File

While there are a lot of methods for you to resize images with php, we will be using extension gd this time. Make sure you or your hosting company has installed it in the php distribution by running <?php if (extension_loaded(‘gd’)) { // return true if the extension’s loaded. echo ‘Installed.’; } else { if …

PHP: Resize Image and Store to File Read More »

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax …

Scratching your head for a mystic error in your SQL query? No matter how you look into it, it just seems right and should by the God’s name work as you have wished. But it doesn’t and keeps pumping out annoying SQL syntax errors. Don’t panic, I have a few tips on this that might …

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax … Read More »

PHP Array Length Function to Get Length of Arrays

PHP Arrays are collections of items identified and ordered by index. Array length is just the number of elements it contains. For an array: <?php $greetings = array( ‘Good morning!’, ‘Good afternoon!’, ‘Good evening!’ ); ?> The length of array in PHP code above is simply the number of strings contained in it, in this …

PHP Array Length Function to Get Length of Arrays Read More »

Which is better for AJAX requests, GET or POST?

As per HTTP protocol specifications, client browsers send http post requests in two-step processes: 1) send the headers, 2) send the data. Therefore, for websites with high volume traffic, it’s definitely preferable to choose GET method for AJAX requests over HTTP, because all it takes for GET to get out is a URL request, which …

Which is better for AJAX requests, GET or POST? Read More »

How to pass variable values in URL from page to page with PHP?

You can see dynamic URLs everywhere on the web with busy interactive sites. Variables and their values are passed from one page to another in this way. Or more precisely, a page served in PHP (a single file php script) can accept external input in the form of a dynamic URL such as http://www.asite.com/[email protected]&subject=hi&body=bye. In …

How to pass variable values in URL from page to page with PHP? Read More »

Using JavaScript to Open Excel and Word Files in HTML

One of the main reasons that you might need this is that Microsoft Excel and Word documents pervade. They are perfect media to store, display and distribute information and ideas. A rather straightforward approach is to simply link that document up. <a href=”bank/sheet.xls” >some excel file</a> Another approach is via JavaScript. <script type=”text/javascript”> function openExcel(strFilePath) …

Using JavaScript to Open Excel and Word Files in HTML Read More »

SQL: INSERT INTO … SELECT … to generate or combine records from existing ones and insert into an existing table

Update: Here is a more advanced use of INSERT INTO … SELECT … to combine multiple tables into one. While CREATE TABLE … SELECT … mix and mingle records by column from other tables into a table that’s created on the fly, INSERT INTO … SELECT … insert those generated or combined records into an …

SQL: INSERT INTO … SELECT … to generate or combine records from existing ones and insert into an existing table Read More »

SQL: CREATE TABLE … SELECT … to generate new table from existing tables

CREATE TABLE … SELECT comes rather useful when you need to generate reports from existing tables or do a mixture. The title just shows the basic usage of it, for instance, to create a new table xxx from 2 columns in yyy, namely col1, col2. After executing SQL: CREATE TABLE xxx SELECT col1, col2 FROM …

SQL: CREATE TABLE … SELECT … to generate new table from existing tables Read More »

How to build a php query string without question mark

As a result of the spreading SEO awareness and how Google works, it is always recommended to use as less dynamic URLs as possible for your site. If one must, try using as less variables in the dynamic URL as possible. A dynamic URL is one with a question mark that passes dynamic variables to …

How to build a php query string without question mark Read More »

Using JavaScript to refresh and reload an iframe on main page

<iframe></iframe> is useful in many aspects. There are times when you want to refresh the content of an iframe and reload the page in it, without refreshing that of the main page, and it can be achieved with a tiny property of iframe, src. Let’s say you have an iframe of captcha that enables the …

Using JavaScript to refresh and reload an iframe on main page Read More »

Check for file size with JavaScript before uploading

File uploading is a rather common feature of interactive sites. As all servers come with a limit on the size of the file being uploaded, it would be a usability blessing for users if web developers can implement a logic to check for the file size before uploading, informing the user if the size of …

Check for file size with JavaScript before uploading Read More »

Scroll to Top