Increase your concentration and productivity by beating noise with more noise!

“Working from a public space involves dealing with noise levels
that are for me, entirely counterproductive.”

Getting distracted by noise while programming?  Suffering from not being able to concentrate whilst developing and being interrupted by annoying noises?

“What about listening to a white noise app?”

You can beat that annoying noise with white noise, get focused and download a free app from Google Play called “White Noise Free” or on iTunes, or use this website Noisli.

“White noise is excellent,  I use it to drown everything else out.”

MySQL phpMyAdmin Tutorial, creating tables and joining tables together

Check out my first video tutorial on YouTube.

I’m demonstrating MySQL phpMyAdmin, to get you started creating a database, creating and populating two MySQL tables and a simple SELECT statement showing how to join the two tables together.

The text size does look a little small, so the next video will be zoomed in to make it easier to see, stay tuned for more.

If you have any questions you would like answered in a video, just leave them in comments below.

Thanks,

Jon

How to protect your PHP source code with encryption?

Worried about giving away your PHP source code?

Want to protect your code when delivering it to a clients hosting when it’s not paid for yet?

I know as this has happened to me. I found a delivery of PHP code for sign off encrypted, I hadn’t seen that before. When we asked the company they said they would remove the encryption upon final payment.

Encryption is definitely a useful tool for PHP developers. Make it a deliverable of your contract that the source code will be decrypted when paid for.

We also had another client who wanted to distribute PHP code on USB thumb sticks.  Not recommended, but it is possible to run it like that, using a SQLite database.  Given the accessibility of a USB thumb stick rather than a Linux server, we encrypted the PHP code.

Here’s a couple of PHP encoders that we’ve used:

So encode, obfuscate and protect your code, if you feel the need to!

Please leave a comment below or sign-up for email updates on new blog post.

If you are using file_get_contents you might want to check out PHP Simple HTML DOM Parser

PHP Simple HTML DOM Parser is a great tool to process HTML from remote sites.  The HTML is returned from the library. So that you can then search and iterate through it, this is great for scraping sites.  I didn’t write the code, but you can download it here and find some simple documentation:

http://simplehtmldom.sourceforge.net/

Usage is really simple, just include the file:

If you liked this tip, be sure to subscribe below and be the first to get my next tip…

New to PHP and need some help with errors?

Wondering what’s going on with your variables?

Not seeing what you are expecting?

If you are a newbie learning PHP, one of the most useful functions to know is var_dump().

It dumps the contents of a variable, so you can see it in your web browser, it’s simple to use for example:

var_dump($my_variable);

Then you can see what $my_variable contains. The data type and in the case of an array or an object. The structure will then be visible.
You will then know how to access the fields within the array / object.

Although I’m far from a newbie, var_dump() is an ever useful function. Use it to determine the value of variables and debugging your code.

var_dump() is your friend in many scenarios, remember it and use it while developing.

Example usage, if you want to see all the variables in a GET or POST request:

var_dump($_POST);
var_dump($_GET);

To all the variables in the SERVER global variable:

var_dump($_SERVER);

To check what’s stored in the session:

var_dump($_SESSION);

How to join three MySQL database tables together in a simple SELECT statement

Following on from my post of how to join two MySQL tables together, adding a third table is just as easy, but if you need an example this one extends the previous post by adding a third table.

For example I have a table of products, table of product categories and table of product suppliers, how to return the category description of each product and the supplier of the product?

Products
———–
id
category_id
supplier_id
product_name

Categories
————-
id
description

Suppliers
—————
id
supplier_name
supplier_address

In it’s simplest form you would join three tables based on the relationship between a key and it’s foreign key stored in another table:

SELECT p.id, p.product_name, c.description AS ‘cat_description’, s.supplier_name
FROM products p
INNER JOIN categories c on p.category_id = c.id
INNER JOIN suppliers s ON p.supplier_id = s.id

Using a well designed relational database and JOINed queries will make your PHP code simpler and more efficient by returning the data from two or more tables in one query.

Like this post? please leave a comment below:

How to join two MySQL database tables together in a simple SELECT statement

How to join two MySQL database tables together in a simple SELECT statement?
For example I have a table of products and a table of product categories, how to return the category description of each product?
Products
———–
id
category_id
product_name

Categories
————-
id
description

A. In it’s simplest form you would join two tables based on the relationship between a key and it’s foreign key stored in another table:
SELECT p.id, p.product_name, c.description AS ‘cat_description’
FROM products p
INNER JOIN categories c on p.category_id = c.id

Using a well designed relational database and JOINed queries will make your PHP code simpler and more efficient by returning the data from two or more tables in one query.

Like this post? please leave a comment below: