Sunday, April 3, 2016

Embed Facebook Page Timeline on Your Website — Page Plugin Guide

Greetings Of the day!!!

Quick summary

I was working on a website and wanted to include updates from my Facebook Page on the site. I found a simple solution in Facebook's developer console. Below is the exact process I used to include Facebook Page updates on a website.

What you'll need

  • The public URL of your Facebook Page
  • Access to edit your website's HTML (so you can paste the code)
  • A moment to configure the Page Plugin at Facebook Developers

Step-by-step

  1. Go to the Page Plugin page on Facebook Developers:

https://developers.facebook.com/docs/plugins/page-plugin/

  1. Enter the details about the Facebook Page (your Page URL and the display options you want).

  2. After entering all the details, press the "Get Code" button.

Facebook Page Plugin configuration screenshot

  1. Copy the code that pops up after pressing the Get Code button.

Get Code popup screenshot

  1. You can paste this code in the HTML file of your website. After pasting, you should be able to see the Facebook Page with Like and Share buttons and all the status updates on the page.

Code copy screenshot

Example

You can visit the site I used for this example: http://drvbhosagoudar-bioresearch.org/ — you should see the Facebook Page plugin on the left side of that site.

Notes and tips

  • The Facebook Page Plugin generates code for you. Paste exactly what Facebook returns in the "Get Code" popup into your HTML where appropriate. Typically, Facebook provides a small JavaScript SDK snippet and an iframe option — follow the instructions in the popup.
  • If you are using a CMS (Blogger, WordPress, etc.), paste the provided markup into an HTML/Custom HTML widget or into the template where you want the plugin to appear.
  • If the Facebook developer console UI looks different, check Facebook's Page Plugin documentation (link above) — the UI and options occasionally change.

That's it. Happy coding.

Friday, April 1, 2016

How to import an .sql file into MySQL from the command line

When I was working with the MySql command prompt, I was wondering how to import an available sql file into the available database.

Overview

This short guide shows two simple ways to import an .sql file into an existing MySQL database from the command line:

  • Using the mysql client interactive prompt with the SOURCE command
  • From the operating-system shell using input redirection (<)

Prerequisites

  • MySQL client (mysql) installed and on your PATH
  • Database already created (you will import into an existing database)
  • Credentials (username and password) with permissions to create/modify tables in the target database
  • Path to the .sql file you want to import (absolute or relative)

Method 1 — inside the mysql client using SOURCE

  1. Open the MySQL command prompt and select the target database. In the example below the database is named smartcart:
mysql> use smartcart;
Database changed
  1. Use the SOURCE command with the path to your .sql file. The example uses f:/items.sql:
mysql> source f:/items.sql;
Query OK, 0 rows affected (0.07 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.76 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)
  1. Verify that the new table(s) from the SQL file were added to the database:
mysql> show tables;
+---------------------+
| Tables_in_smartcart |
+---------------------+
| items               |
| users               |
+---------------------+
2 rows in set (0.00 sec)

mysql> select * from items;
Empty set (0.06 sec)

Notes for Method 1:

  • The path you pass to SOURCE can be absolute or relative to the server/your client working directory. On Windows you can use drive letters (e.g. f:/items.sql) or surround paths with quotes if they contain spaces.
  • SOURCE runs all SQL statements in the file as if you typed them into the client.

Method 2 — from the OS shell using input redirection

You can import an SQL file directly from your command shell without first entering the mysql prompt. This is often faster for large files.

Example:

# From a Unix/Linux/macOS or Windows PowerShell/CMD shell
mysql -u username -p smartcart < f:/items.sql
# You will be prompted for the MySQL password

Notes for Method 2:

  • Replace username with your MySQL user and smartcart with the target database name.
  • If you omit the database name you can still import statements that include CREATE DATABASE / USE statements.
  • On Windows, ensure the path syntax is correct (you can also use double backslashes or forward slashes).

Troubleshooting and tips

  • Permissions: make sure the user you connect with has the required permissions on the target database.
  • File path: if you see "file not found" errors, verify the path and quoting. Try an absolute path.
  • Empty table after import: the file may only contain schema (CREATE TABLE) statements or no INSERT statements. Open the .sql file to confirm it contains INSERTs if you expect data.
  • Errors during import: the mysql client will print errors as it executes statements. Rerun the import after fixing the SQL or adjust the error-handling behavior (for automation, consider mysql --force to continue past errors).
  • Character set issues: if you see strange characters, specify --default-character-set=utf8mb4 (or appropriate charset) when invoking mysql.

Summary

Both SOURCE (inside the mysql client) and shell redirection (mysql < file.sql) are valid ways to import an .sql file. Use the method that fits your workflow: interactive debugging inside mysql or direct shell import for automation/large files.

That's it. Happy coding.