Friday, 19 December 2014

Wordpress title repeated two times in browser header [SOLVED]

Wordpress title repeated two times in browser header [SOLVED]

I add the post from wordpress admin section (http://www.example.com/wp-admin/), 
After publishing the post it start displaying in website.

In Post detail page, Every information like post title, post description and post date etc is correct except meta title.


Issue: Meta title have post name + website name + | website name.

Here meta title have website name two times at then end of page title.


Solution: 
  • Login into admin section.
  • Go to Plugins section. ( or use link: http://example.com/wp-admin/plugins.php).
  • Search for "All in One SEO Pack".
  • Click on deactivate, Now "All in One SEO Pack" is deactivated successfully.
  • Go to website and refresh the Frontend page, Now you will see two times website name in title is FIXED.

Thursday, 18 December 2014

How can I prevent SQL-injection in PHP [SOLVED]

How can I prevent SQL-injection in PHP [SOLVED]

Following are different 3 ways to prevent from SQL Injection.
1. Using PHP inbuilt Functions.
$name = mysql_real_escape_string($_POST["name"]);
mysql_query("INSERT INTO users VALUES($name)");


2. Use MySqli instead of MySQL. MySqli is far better than MySql because is object oriented MySql.
$stmt = $dbConnection->prepare('INSERT INTO users VALUES(?)');
$name=$_POST["name"];
$stmt->bind_param('s', $name);
$stmt->execute();


3. Using PDO
$stmt = $conn->prepare("INSERT INTO users VALUES(:name)");
$stmt->bindValue(':name', $_POST["name"]);
$stmt->execute();