- When we create tables on the MySQL database, we assign values to length, On that time we assign some number to length like,
Email– type: varchar and length: 200 (This means you give to email maximum 200 characters and type is a variable character).
UserName– type : varchar and length: 100 (This means you give to email maximum 100 charaters and type is variable character)This length can increase the time of the processing of the website and if you have many of the fields like these your website might be slow somewhere.
Solution: Give length to the field which is required only Means, you can think 200 is a very big character length for email, no one has an email with 200 characters long.
So give required value to the length of the field. And also same for UserName field for this example.- The second thing is when you write some query on PHP code like given below,
Query:
$query = "SELECT * FROM table_name";
OR
$query = "SELECT
field1
,field2
,field3
FROM table_name";Somewhere both are the same but the only thing is 2nd one is optimizable where 1st one is not.
Reason For:$query = "SELECT * FROM table_name";
When you use this code, on output this query selects all the fields of that table which is take more time than 2nd query. Beacuse on 2nd query we call only those fields which we want or required for our program.
So always code like this for better optimization.
- The second thing is when you write some query on PHP code like given below,
Hey! I just wanted to ask if you ever have
any problems with hackers? My last blog (wordpress) was hacked and I ended up losing
a few months of hard work due to no data backup.
Do you have any solutions to stop hackers?
Here are some pointers to prevent hacking a WordPress site,
1. Use lock feature means if anyone login again and again with wrong password site gets locked for some time, this also prevents your site from Brute Force attack.
2. Use two-factor authentication login feature, use google authenticator plugin for that.
3. The WP Admin folder is the main part of your project, so first, protect that password, use the AskApache Password Protect plugin for securing the admin area.
4. Replace wp-login.php to something unique like SITENAME_LOGIN
Replace /wp-admin/ to something unique like, SITENAME_LOGIN_ADMIN
5. Don’t use pirated themes and plugins. Backup regularly for the security of your site.