There are 3 types of loop in PHP:
while (condition)
{ code_goes_here; }
do
{ code_goes_here; }
while (condition);
for(expr1, expr2, expr3)
{ code_goes_here; }
In terms of the ‘for’ loop above, ‘expr1′ being the starting expression, i.e. $i=0. expr2 being the condition that must be satisfied to keep the loop running, i.e. $i < 100. expr3 being the expression evaluated each time the loop runs, i.e. $i++. Each loop type has it’s uses.
(more…)
Tags: do, for, loop, MySQL, PHP, PHP Developer, PHP MySQL Developer
I’m often asked how to copy or export MySQL Users from one machine to another. The following SQL query will show your users:
SELECT DISTINCT CONCAT (‘show grants for `’, user, ‘`@`’, host, ‘`;’) AS query FROM mysql.user;
In my case on my test server, this shows:
SHOW GRANTS FOR ‘root’@’127.0.0.1′;
SHOW GRANTS FOR ‘debian-sys-maint’@'localhost’;
SHOW GRANTS FOR ‘root’@'localhost’;
Now, I’ll need to execute each one of these as separate statements. The output of SHOW GRANTS FOR ‘root’@'localhost’; is:
GRANT ALL PRIVILEGES ON *.* TO ‘root’@'localhost’ IDENTIFIED BY PASSWORD ‘*XXX…XXX’ WITH GRANT OPTION;
Copy and paste each ‘GRANT’ statement to your new SQL server, with the hashed password intact and you should be ready to go.
Tags: PHP MySQL Developer, sql
All major programming languages have it, it’s the modulo operator, and it has multiple uses. First I’m going to explain what it is, then I’m going to demonstrate one very simple, very powerful use.
Programatically, the modulo operator is most commonly denoted with a percentage ‘%’ symbol. Given two numbers as input, the modulo operator returns the remainder after division. p = a%b; will return the remainder after a is divided by b.
Here are some examples:
2%2 = 0 (2 divided by 2 = 1 remainder 0)
6%2 = 0 (6 divided by 2 = 3 remainder 0)
7%2 = 1 (7 divided by 2 = 3 remainder 1)
18%4 = 2 (18 divided by 4 = 4 remainder 2)
The modulo operator is used extensively in cryptography, Diffie-Hellman (DH) Key Exchange is just one example.
As a PHP Programmer, what can this be useful for?
(more…)
Tags: modulo operator, PHP, PHP MySQL Developer, php programmer
Being a Freelance PHP MySQL Application Developer based in London has some major advantages as I found out today. The majority of both mine and my firm’s work is conducted online. Video conferencing over Skype, code delivery over SVN (Subversion), and bug tracking through Basecamp. Once in a while though an opportunity for a site visit in or around central London/West End pops up, and, schedule permitting, I’ll more often than not be happy to accept.
My core focus is on web application development, and being London based, I’ve had a chance to work with some great Companies. I’m currently at the time of writing, spending a few hours per week overseeing and managing a team of developers rewriting a wireless hotspot provider’s intranet which is proving to be very challenging, and great fun.
For more information on what it is that I actually do in the PHP/MySQL field, please view my PHP MySQL Developer series!
Tags: MySQL, PHP, php mysql, PHP MySQL Developer, php mysql developer london
Setting up a PHP/MySQL/Apache2 environment on Debian is really easy, and as a PHP MySQL Developer, it’s kinda important! I’ll walk through a quick Debian lamp install howto and optimization process. I’ve optimized it for a 1.5Gb to 2GB RAM machine with reasonable load.
mysqladmin password ‘NEWPASSWORD’
Now download eaccelerator from http://eaccelerator.net
(more…)
Tags: apache2 optimization, debian, Debian lamp install howto, Development, LAMP, LAMP Optimization, MySQL, mysql optimization, Optimization, PHP, PHP Developer, PHP MySQL Developer, php optimization, php5, Programmer