Group By and Order By

In MySQL query, GROUP BY and ORDER BY will give you 2 different results. Group By will return the unique values of a field while Order By will return number of records with alphabetical or numeric order based on what field you specify. This is an example of query using Group By, you will see that the results will only list a unique lastname: SELECT firstname, lastname, email_address FROM somedb.users GROUP BY lastname; The results will be: Alice, Bloom, bloom@gmail.com Daniel, Nguyen, dnguyen@yahoo.com Lynda, Dina, dina@mail.com While the query using…

Continue reading »

How to set up configuration file for multiple servers

If you install Joomla on multiple servers, you can have a config file that works on all servers. You don’t have to change the config file everytime you copy to a different host. I will show you how to do it easily, so you can work on a development server as well as production server without breaking the site. Open the config file in Joomla root folder. You can use Notepad or any PHP Editor. Add a condition statement “if else” right before the class JConfig. $server =…

Continue reading »

Creating a directory in php

If your website is shared on *nix server, a directory created through mkdir() will not be assigned to you, but to the user that your host’s server or php process is running under, usually ”apache’ or ‘httpd’. In practice, this means that you can create directories, even add files to them, but you can’t delete the directory or its contents nor change permissions to a directory. It is therefore advised to create directories through PHP’s FTP API using PHP function. This is a function I…

Continue reading »

How to build an external function login to phpBB forums

Today, I will show you how to build a function to log in a user from outside of the phpBB forums. Your forums has to be version phpBB3. First of all, empty all files in the cache directory of your forums. Build a single file and name it something like login_from_outside.php and place it in the root of your forums directory. Define a line to protect your file from hackers: define(‘IN_PHPBB’, true); Then include the following functions and common files from forums libraries. Remember to define the proper root path according…

Continue reading »

Tips for PHP Developers

I have 3 different servers with 3 different environment settings (2 Windows servers and 1 Linux server). So every time I moved my files from 1 server to another, it’s broken because database credentials or file systems are different. Therefore, I come up with the environment check before any next logic is in place. $env_check = getenv(‘windir’); This line will output ‘C:\WINDOWS’ if your codes are on Windows server. And empty if it’s on Linux. Now I can use condition to control the different credentials…

Continue reading »