Subscribe to this blog

Follow by Email

Is it a variable or is it a value?

LoL, just wiped up a quick script for the ad banners on my web site. I want to use different shaped banners in different locations on the website, but I do not want to make a separate file for the code of each ad. Why would I make a separate file for the code of each ad? Why do not I simply past the code in the page I am working on? Well, there are few reasons why I am doing that. They are as follows:

I love to make separate files for parts of code I use often and then including it in pages.

It is easier to work on code if it is in one location instead of having to edit and updated a whole load of pages.

Yes and I am still using include files, although I love mixing SQL and PHP, I still have not completely converted my site to query the pages code from a database. Something I am planning on doing in the coming months. LoL

But back to the script I was working on. It took all about 2 minutes to write it. But damn, it took me 25 minutes to figure out what my problem was. I would pass in values, but for some reason the script did not deliver. Even though I looked over my code bunch of times, I just could not figure out what the problem was. I Googled other scripts and looked over them, but still nothing. Then I again, I looked over my code and it hit me when I saw what I had done. It was a simple and silly mistake. Instead of comparing my variables to the values being passed in, I was comparing them to other variables in the script. Silly so silly!!!

Popular posts from this blog

I am currently working on a project which will allow users to register their Wi-Fi enabled, non-web browser enabled, devices on the network. These are devices like printers, Apple TV, and Xbox*. One of the data points that have to be collected from the user is the device MAC address. The project customer wants that address to be properly formatted when they see it in the support ticket.

We have several options. We can format the address either on the back-end after the form has been submitted. Or we can format it on the front end via a separate text field for each character pair, but that is too many fields to handle. A better solution is to use a single field and format the user input at the time of input or upon submit. In those cases, the former is better because the data will already be formatted when the overall form input is being validation after the user clicks the “Submit” button.

We are going to format the user input as it is being provided, thus having proper data when vali…

A recent project I worked on allowed customers to request cloud computing resources. One of the requirements was to display the cost for each resource amount and the totals for one and two years for the resources the customer was requesting. In the United States, numbers are formatted with a period for the decimal mark and a comma as the thousands separator, e.g. 1,234,567.89. The function below is going to: Assume that the input is either an unsigned integer or a float, ex. 1234567 or 1234567.90.Insert a "," delimiter every third digit.Optionally, add a currency symbol to the returned string. https://gist.github.com/thetitan/328a68da79f97d1ee27c5509cc91bf56#file-formatcostnumber-js Let’s review: On lines 2 - 4 I defined some default values.On line 6 I defined a closure called formatNumber. The logic in the closure is going to format the number string.Starting at line 28 I am making sure that when the formatCostNumber function is called it does receive a value to format, and that…

If you have a WordPress based blog, or otherwise use WordPress as a CMS for your website, you are either getting a lot of bad user accounts being created or noticing a lot of knocking on your wp-login.php page. WordPress has a nice feature which allows you to install WordPress in a directory other than the root one. For example, your site is served from http://blog.example.com, but WordPress can be installed in http://blog.example.com/wpcms. In past versions of WordPress, prior to 3.8 or maybe be older than that, unless you knew the exact path to where WordPress was installed you could not get to the dashboard. That has changed! Now even if WordPress is installed in some random directory, if you navigate to http://blog.example.com/wp-login.php you will be redirected to the actual WordPress login page. Convenient, but not helpful when dealing with SPAM bots.