msgbartop
Adam Palmer MBCS CITP, Linux, PHP Programmer, MySQL Developer, Embedded Hardware, Security Consultant
Did my blog help you? Please link to me!
  dns test
 
RSS Feed
msgbarbottom

15 Nov 09 PHP Developer – Loops in General

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: , , , , , ,

13 Oct 09 Copy/Export MySQL User Priviledges

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: ,

05 Oct 09 PHP Programmer – Modulo Operator

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: , , ,

26 Sep 09 PHP MySQL Developer – A Freelancer in London

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: , , , ,

07 Oct 08 PHP, MySQL, Apache2 install HOWTO on Debian

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.

apt-get install apache2 php5 mysql-server-5.0 mysql-client-5.0 libapache2-mod-php5 php5-mysql php5-curl php5-cli php5-dev make gcc libc6-dev automake

mysqladmin password ‘NEWPASSWORD’

Now download eaccelerator from http://eaccelerator.net
(more…)

Tags: , , , , , , , , , , , , , ,