Check if MySQLi extension is enabled with PHP

Checking if the MYSQLi extension is installed and enabled is pretty straight forward. We can call the function_exists() on a mysqli function and that will give us true or false, depending on the server, if it’s installed or not.

This can be quickly adapted to other usages, like checking for the GD Library extension or anything else.


Check if a domain is Registered with PHP

Hi there guys! We are going to look at a very simple php snippet that lets you know if a specific domain is registered / available for purchase or not.You could expand / grow this snippet and make your own website that checks websites domains for availability. To check if a domain is registered or not we will use the checkdnsrr function that PHP provides us.This function searches for the DNS records of the specific website / domain and if they aren’t available that means the domain isn’t registered.Here is a simple script that you can use:

All you need to do is replace the value of the $domain variable with the one you want to check and you’re good to go.For this example, the result / output is: is already registered !


OOP MySQLi : How to use Prepared Statements

Hi there guys ! In the last tutorial we talked about How to connect to your database via MySQLi and today we are going to discuss a very important topic in learning how to handle the new MySQLi.If you didn’t read the first article on MySQLi, I suggest you check it out before.

Why use Prepared Statements?

  • Security – You won’t need to escape characters when using prepared statements
  • Perfomance – The statement is prepared only once, but you can execute it multiple times
  • Possibly Cleaner Code – As you won’t need to escape the variables, you are writing less and more organised code

Downsides of Prepared Statements

The first downside of using prepared statements that I can think of it that you can echo out the query so that you can easily check if you created the query correctly or if you have some errors and you want to debug it, you can easily output it and see what’s wrong.As with the Prepared statements, you can’t echo out the query.Another downside is that it can be confusing at start if you don’t have much background in programming but that shouldn’t scare you.I encourage you guys to learn how to use prepared statements.

How to use Prepared Statements

Alright, so you’ve decided to learn how to use Prepared Statements, that’s a really good thing and will definitely help you in your future projects.
$database – variable which contains the OOP database connection.


Alright, so you are probably asking what we just did.. When we prepare the statement, instead of using WHERE id = {$id}like we would’ve used normally we replaced the variable with a question mark ( ? ).If you have more than one variable, for example you have WHERE email = {$email} AND id = {$id}.All you need to do is replace all the variables from the query with ? so we would have this query WHERE email = ? AND id = ?.


What does bind_param() do? Well, remember the ? (question mark) signs that we just used ? I guess you already figured it out what it does, but I’ll tell you anyway.It binds / assigns every question mark you used with the prepare() function in the beginning with a variable.

It requires 2 or more parameters.The first parameter will always be a string which contains the type of variable you are sending to the database.I know it sounds weird but let me give you and example, examples are good.Lets say we have 2 variables that we want to assign, $email and $id.The email variable is a string so we will use the s character and for the id variable, which is an integer we’ll use the i character.Check out this example.

The s represents the type of the $email variable and the i represents the type of the $id variable.

I hope you learned something today, thanks for reading my tutorial.Stay tune for the part 2 where we learn to execute the statement and if needed get some results from the database.



OOP MySQLi : Connect to your database

Why should you use MySQLI ?

Firstly, MySQLi stand for: MySQL Improved. Since PHP 5.5.0 old mysql extension is deprecated and will soon be removed.This is the first reason you should use mysqli over mysql.

Secondly and what I think it’s the most important and useful feature that mysqli give us is that you can use prepared statements for your queries.That is a much much safer way of querying your database and preventing sql injection.

Connecting to your database using MySQLi

Create a new file named something like connect.php, database.php or whatever your want.Now open it with your favourite text editor.

First thing we need to do is defining the variables which contain information of your database, of course you don’t need to define them but it’s a much cleaner and will may be helpful later in your projects.

Great, we are now ready to proceed to actually connecting to the database using the new mysql improved extension by adding this variable.

After this you are pretty much all set and you can test it on your localhost or webhost and if you get no errors and the page is blank then you connected successfully to your database.

I personally like to let it as it is without checking for errors because if there is any error php will automatically tell you that something went wrong.For example if you have a larger PHP project and you setup your database connection wrong, you can easily tell because of all the errors you will get all over the page if the database connection doesn’t work.

Thats it for today’s tutorial, I will probably do part 2 very soon for you guys.Thanks for reading !


PHP Seconds to Days, Hours, Minutes, Seconds

Hi there guys, today I’m going to give you a little snippet that I found on the web which I find very useful and I thought I should share it with you.This function will require 1 parameter, the number of the seconds you want to transform into Days, Hours, Minutes, Seconds.

e.g: 600000 = 6 days, 22 hours, 40 minutes, 0 seconds

Hope you find it useful, I sure did !


Fixing PHPMyAdmin & Database Connection working slow on windows 8

Hi there guys, today I’m going to tell you a little trick on how to fix a problem which many of you coders have with windows 8.I had that problem too and I was very annoyed by the fact that PHP My Admin was working so slow almost 2 seconds delay, which is extremely slow.

I’m not sure why it has a 1 second delay for every query but I know how to fix this.Instead of using “localhost” on your connection to mysql, use “” and you will get rid of the delay. For example :

Use this:


Instead of this:

If you want to fix the delay on PHP My Admin you need to find this file and edit it ( xampp/phpMyAdmin/ )

Add this line at the bottom of the page

And thats it, thanks for reading my tutorial and I hope it helps !