Saturday, 3 December 2016

Importing Large Size of database into PhpMyadmin using Commandprompt

First, copy the database file ( .sql ) to this path

C:\wamp\bin\mysql\mysql5.6.17\bin

the number after  mysql maychange depending on which version of wamp/mysql do you have.. but in normal cases, it will be only one folder there in mysql folder. so enter it and then go to 'bin' folder and copy the .sql there...


then. open the command prompt from Start>All Programs>Command Prompt.. you may have to right click on it's icon and click Run As Administrator so you just be in safe without problems...

if you opened the command prompt, type there

CD C:\wamp\bin\mysql\mysql5.6.17\bin

Note the space after CD in the begining, then hit enter

this should change the directory on the command prompt to that directory

now prepare for the command, you will need the datebase name ( you must created it before ), and the database username ( default for wamp is root ) and database password ( default for wamp is nothing, no password is set )

type the following command

mysql -u [DATABASE_USERNAME] -p [DATABASE_NAME] < [DATABASE_FILE.SQL]

replace the brackets with the correct values, for example if your database name is mydb and the sql file is db.sql and you use the default username and password for the database then the line will be

mysql -u root -p mydb < db.sql

After that hit enter.. it will ask you the password, if it's empty just hit enter again or type it then enter.. then it will restore the db.. for a db this size it will take seconds only...

Saturday, 5 November 2016

Enabling Bootloader Customizer in Linux

When we install 2 or more Operating system in our PC, sometimes we have to make changes to the bootloader priority. Like we have to enable windows should boot first than linux or sometime linux should boot first than windows. So For this we have to change in grub settings in linux. So Easy method is to install Grub Customizer in Ubuntu.

So for this open terminal and execute following commands.

sudo add-apt-repository ppa:danielrichter2007/grub-customizer

sudo apt-get update

sudo apt-get install grub-customizer

Tuesday, 18 October 2016

Enabling Other Computer to Access Wamp server in a Windows PC in same Network

When you work for a large project, their will be situation comes where you have to share your wamp server with other persons on the same networks, especially when the project is not hosted else where.
For Linux Users it wont be a problem beacause, by default this is enabled in linux systems. You can access from other pcs of a Linux wamp server at any time. Just browse by :- http://ipaddress/

So In case of Windows to enable this facility, we have to do some configuration in our wamp settings. So am going to explain what to do for this:-



For WampServer 2.5 and previous versions

WAMPServer is designed to be a single seat developers tool. Apache is therefore configure by default to only allow access from the PC running the server i.e. localhost or 127.0.0.1 or ::1
But as it is a full version of Apache all you need is a little knowledge of the server you are using.
The simple ( hammer to crack a nut ) way is to use the 'Put Online' wampmanager menu option.
left click wampmanager icon -> Put Online
This however tells Apache it can accept connections from any ip address in the universe. That's not a problem as long as you have not port forwarded port 80 on your router, or never ever will attempt to in the future.
The more sensible way is to edit the httpd.conf file ( again using the wampmanager menu's ) and change the Apache access security manually.
left click wampmanager icon -> Apache -> httpd.conf
This launches the httpd.conf file in notepad.
Look for this section of this file
<Directory "d:/wamp/www">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
#    Require all granted
#   onlineoffline tag - don't remove
     Order Deny,Allow
     Deny from all
     Allow from 127.0.0.1
     Allow from ::1
     Allow from localhost
</Directory>
Now assuming your local network subnet uses the address range 192.168.0.?
Add this line after Allow from localhost
Allow from 192.168.0
This will tell Apache that it is allowed to be accessed from any ip address on that subnet. Of course you will need to check that your router is set to use the 192.168.0 range.
This is simply done by entering this command from a command window ipconfig and looking at the line labeled IPv4 Address. you then use the first 3 sections of the address you see in there.
For example if yours looked like this:-
IPv4 Address. . . . . . . . . . . : 192.168.2.11
You would use
Allow from 192.168.2
UPDATE for Apache 2.4 users
Of course if you are using Apache 2.4 the syntax for this has changed.
You should replace ALL of this section :
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
Allow from localhost
With this, using the new Apache 2.4 syntax
Require local
Require ip 192.168.0
You should not just add this into httpd.conf it must be a replace.

For WAMPServer 3 and above

In WAMPSevrer 3 there is a Virtual Host defined by default. Therefore the above suggestions do not work.
Instead, leave the server OFFLINE as this funtionality is defunct and no longer works, which is why the Online/Offline menu has become optional and turned off by default.
Now you should edit the \wamp\bin\apache\apache{version}\conf\extra\httpd-vhosts.conf file. In WAMPServer3.6 there is actually a menu that will open this file in your editor
left click wampmanager -> Apache -> httpd-vhost.conf
just like the one that has always existsed that edits your httpd.conf file.
It should look like this if you have not added any of your own Virtual Hosts
#
# Virtual Hosts
#

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot c:/wamp/www
    <Directory  "c:/wamp/www/">
        Options +Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>
Now simply change the Require parameter to suite your needs EG
If you want to allow access from anywhere replace Require local with
Require all granted
If you want to be more specific and secure and only allow ip addresses within your subnet add access rights like this to allow any PC in your subnet
Require local
Require ip 192.168.1
Or to be even more specific
Require local
Require ip 192.168.1.100
Require ip 192.168.1.101

Thursday, 13 October 2016

Laravel Sample Project for Beginners with CRUD Functions

Starting The Project

Download Sample project from :-
 Download: https://github.com/litto/Laravel5--Sample-Project--Including-CRUD-Functions

In this blog Iam going to explain a Sample project with all functions that is needed like Creating, Updating, Deletion,File Uploading, Routing, Session management.etc.. Hope you hav installed laravel project as I explained in my previous post. If not read it :-

http://phpdudes.blogspot.ae/2016/10/laravel-5-installation-steps-for.html


Creating a Database

1) First Create a db of your preffered name,Iam naming it as Laravel.
2 create tables cms, admin, cms_userauth.
3) cms_admin contain fields like auth_id,username, password.
4) cms_userauth contain fields like user_id,name,email,password

Connecting DB to the project
1) Find a file name .env in the root folder of your project
2) Find the lines

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=newlaravel
DB_USERNAME=root
DB_PASSWORD=

3) Give values for each variables.

4) Your db connection has been established

Folder Structure

This will be your project folder structure :-


I will explain you, purpose of each folder one by one

app − This directory contains the core code of the application.

bootstrap − This directory contains the application bootstrapping script.

config − This directory contains configuration files of application.

database − This folder contains your database migration and seeds.

public − This is the application’s document root. It starts the Laravel application. It also contains the assets of the application like JavaScript, CSS, Images, etc.

resources − This directory contains raw assets such as the LESS & Sass files, localization and language files, and Templates that are rendered as HTML.

storage − This directory contains App storage, like file uploads etc. Framework storage (cache), and application-generated logs.

test − This directory contains various test cases.

vendor − This directory contains composer dependencies.


Start The Project

Routing

Now the important Feature of our project is Routing. It is like explaining which controller & function each url should use.
So, you can find the route configuration file in /app/Http/ folder. Here opne the file named routes.php.

In my I have already defined my routes:-

For eg:

Route::get('/index', array('as' => 'index', 'uses' => 'AdminController@index'));

This means If a request comes like: http://localhost:8000/index . Then this route condition will triggered.
It will use AdminController & function index defined in the controller.

Route::get('/list', array('as' => 'list', 'uses' => 'UserController@index'));

Here If request like http://localhost:8000/list comes then it will use UserController & Function index defined in it.
Now may be you are wondering what is this Controllers & functions & all. I will explaain in the coming portions.

So see another Route line like this:

Route::get('edit/{id}','UserController@edit');

This is for urls like : http://localhost:8000/edit/7
Here the Id will be passed as variable to the Function

Defining Controllers & Views

We will define controllers in the folder /app/ Http/Controllers/
Here For eg: If you need to create a Controller for  User table. Create controller with name: UserController.php

You can see in My project UserController.php

In it I will explain one Function:-
Lets take index function defined their:-

   public function index(){
     $users = DB::table('cms_userauth')->get();
      return view('user_list',['users'=>$users]);
   }

   Here the database functions I will explain later, see the line

    return view('user_list',['users'=>$users]);

   Here when route calls this Controller & function, what it is  doing is that, it will fetch all user details & it is returing a view file named user_list & its passing an array to that file.

   Defining Views

   In previous Function it is calling a view file right? Actually It is the view for users.
   This is defined in /resources/views/ folder.
   Here in my project you can see user_list.blade.php
   This File willl be displayed.. For knowing about why blade.php extension comes. Actually It is a laravel templating function. For more details about blade template check in Laravel Site.

Installing Html Package

Laravel provides various in built tags to handle HTML forms easily and securely. All the major elements of HTML are generated using Laravel. To support this, we need to add HTML package to Laravel using composer.

Step 1 − Execute the following command to proceed with the same.

composer require illuminate/html

 Now, we need to add this package to Laravel configuration file which is stored at config/app.php. Open this file and you will see a list of Laravel service providers as shown in the following image.


 Step 4 − Add aliases in the same file for HTML and Form. Notice the two lines indicated in the outlined box in the following image and add those two lines.


But there is a bug in this package, I dont know why it is like that. But you can solve taht issue like :-
Navigate to vendors/illuminate/html/HtmlServiceProvider.php
Here change  the lines 36 & 49.
$this->app->bindShared('html', function($app)   to  $this->app->singleton('html', function($app)
$this->app->bindShared('form', function($app)   to  $this->app->singleton('form', function($app)
Changed File will be like this:-



Now Package problem will be solved

Including Css in Views

Now using this Html package templating the method of including css is slightly different. Place your css inside public folder in root.
create a folder named css & include all your css files their.

Now include it in your view file like this:-
 
{!! HTML::style('css/bootstrap.min.css') !!}

Here boostrap.min.css is placed inside css folder


Including Js File in Views

Now using this Html package templating the method of including Js is slightly different. Place your Js inside public folder in root.
create a folder named Js & include all your Js files their.

Now include js file like this:-

{!! HTML::script('js/bootstrap-datepicker.js') !!}

Here js/bootstrap-datepicker.js is placed in the js folder in public.


Including header/ footer Files in Your Views

So In your project mostly we have to include same files in view files like header, footer, menu.etc.. So in Laravel the method is slighly different.
For eg: you have header.blade.php, footer.blade.php & user_list.blade.php in your views folder.
Then to include header & footer in the user_list.blade.php file, You just code like this:-

@include('header')

---------code here------------

@include('footer')

For more clarity check my project included in this post.


Displaying Records in View

So In our Controller , index function we passed a array named users to user_list view right?
So we are displaying in the view like this:-

    @foreach ($users as $user)    
{{ $user->user_id }}  //id displayed
{{ $user->email }} // mail will be displayed

 @endforeach



Creating Forms

Open forms like this
<?php   echo Form::open(array('url' => '/createsubmit','files'=>'true')); ?>

as we have installed Html package, it will defaulty provide form functions like this:-
Just refer in  my project folder & look into each file you will understand clearly.


Create Records in DB (with File Uploading)

While defining Create Submit Form Function dont forget to pass a request parameter in the function definition:-

    public function createsubmit(Request $request){

        $name = $request->input('name');
        $email = $request->input('email');
        $file = $request->file('userfile');
        $destinationPath = 'uploads';
        $file->move($destinationPath,$file->getClientOriginalName());
        $imagename= $file->getClientOriginalName();
if($imagename==''){
$imagename='user.png';
}
DB::table('cms_userauth')->insert(
    array('name' =>$name, 'email' => $email,'photo'=>$imagename,'status'=>1)
);

      echo "Record inserted successfully.<br/>";
      return redirect('list');
   }

Here we can get value of each variable submitted using:-
 $request->input('variable name');  this function

 Image will be uploaded to our defined destination like:-
   $file->move($destinationPath,$file->getClientOriginalName());
   This will upload to the folder uploads we created in public folder..
   File can be viewed by:- <image  height="100px" width="100px" src="/uploads/{{ $user->photo }}"/>
Then  data is inserted in the table cms_userauth as:-

DB::table('cms_userauth')->insert(
    array('name' =>$name, 'email' => $email,'photo'=>$imagename,'status'=>1)
);



Updating Data in DB

DB::table('cms_userauth')->where('user_id',$id)->update(array('name' =>$name, 'email' => $email,'photo'=>$imagename));


Fetching Single Record

$users = DB::table('cms_userauth')->where('user_id', '=', $id)->get();

Fetching all records

  $users = DB::table('cms_userauth')->get();

Fetching records with Condition

$users = DB::table('cms_userauth')
                    ->where('votes', '>', 100)
                    ->orWhere('name', 'John')
                    ->get();

Deleting records

DB::table('cms_userauth')->where('user_id', '=', $id)->delete();

For more Information on DB Queries ..please refer:- https://laravel.com/docs/4.2/queries

Redirecting to another view

For redirecting to one function from other
 return redirect('index');


Sessions in Laravel

For setting a session variable, save like this:

$request->session()->put('loginadminname', $users[0]->username);


For getting all sessions

$data = $request->session()->all();

For deleting all session variables:-

$request->session()->flush();


Now I think u got a little idea about laravel... So for more clarification download my project & go through this post..


Download: https://github.com/litto/Laravel5--Sample-Project--Including-CRUD-Functions



Laravel 5 Installation Steps for Windows & Linux

What is Laravel?

Laravel is a powerful MVC PHP framework, designed for developers who need a simple and elegant toolkit to create full-featured web applications. Laravel was created by Taylor Otwell.

Laravel is a MVC framework with bundles, migrations, and Artisan CLI. Laravel offers a robust set of tools and an application architecture that incorporates many of the best features of frameworks like CodeIgniter, Yii, ASP.NET MVC, Ruby on Rails, Sinatra, and others.

Laravel is an Open Source framework. It has a very rich set of features which will boost the speed of Web Development. If you familiar with Core PHP and Advanced PHP, Laravel will make your task easier. It will save a lot time if you are planning to develop a website from scratch. Not only that, the website built in Laravel is also secure. It prevents the various attacks that can take place on websites.

Installing Laravel (Windows)

1) First step is to install composer in your system. If composer is not present download it from https://getcomposer.org/download/

2) After Composer Installtion, open command prompt & type composer & press enter.


3) We are working on MYsql database . So for that I am expecting your system has wamp server installed & settedup.So For easy development I will explain you steps one by one as i did.

4) In the wamp/www directory, Create a folder as your wish.

5)In Command prompt navigate to that folder and then run command like this:-

composer create-project laravel/laravel

6) So you its will run in terminal & automatically larvel project is generated in laravel folder inside the directory you created.

7)Now Run  this command

php artisan serve

8) Now the terminal will tell you like your production is started at http://localhost:8000/

9) Navigate to that URL through browser.

10) You will get like this :- as shown in below image. Congrtazz your Laravel has been Installed..


Installing Laravel in (Linux)

1) Open Terminal & Run command like

sudo curl -s https://getcomposer.org/installer | /opt/lampp/bin/php

2) This will Install composer in the system.

3) Now run this command in terminal

sudo  mv composer.phar /usr/local/bin/composer  

4)Then to check composer is working or not.. just type composer in terminal.It will show composer commands. So that's working.

5) Then create a folder with anyname eg: laravelworks anywhere in you system . then go to that folder from terminal by using cd command .

6)  Inside that folder from terminal give a command like this .

composer create-project laravel/laravel your-project-name 

7)Next thing we need to do is give permissions to some folders .

i) storage directory
ii) bootstrap/cache

8) you can do that in any way as you like ... i did like this .

first go inside  –prefer-dist using cd command

sudo chmod 777 -R ./storage
sudo chmod 777 -R ./bootstrap/cache


9)After that we need to start a laravel server using following command

php artisan serve

10)   Now the terminal will tell you like your production is started at http://localhost:8000/.
 Congrtazz your Laravel has been Installed..

Thursday, 6 October 2016

Setting Cron Jobs & Folder Sharing in Ubuntu

Commands to set cronjobs in Ubuntu

Login Via root in ubuntu
sudo su
Give Password
type crontab -e

Now a tab will appear, their give crontab line like:-

eg: 30 23 * * * wget http://localhost/crm/yourscript.php
for running a script at  11.30 pm


Folder Sharing

The Procedure is we have to create a user, & group. Then add that user to a group , then at last give permission to the folder for this usergroup.. The commands will be explained with an example below:-

1) Create a User named for eg; developer
adduser developer
smbpasswd -a developer
smbpasswd  -e developer
Give password


2)Create a group named developers

sudo addgroup developers

3) Add User to Group

sudo adduser developer developers

4) Give permission to that folder to the user group

chown -R developer:developers /var/www/foldername

5) Now we have to check whether we installed samba in the computer
Try running this code , If its alreday installed then no pblm.. otherwise install.

sudo apt-get install samba
6) Now in the terminal type like this:-

gksudo gedit /etc/samba/smb.conf

7) Now a file will be opened, in it after the [printer] definition include some lines like this:-

[foldername]
       
        comment = share
        browseable = yes
        path = /var/www/html
       printable= no
       guest ok = yes
       readonly = no
       writable = yes
       valid users = @developers
       write list = developer
      create mask = 0775
      directory mask = 0775



Thursday, 11 August 2016

PHP PDO Simple Library With CRUD Functions

Download the library files  from: https://github.com/litto/PHP-PDO-Simple-LIbrary

#
## To use the class
#### 1. Edit the database settings in the settings.ini.php
### Note if PDO is loading slow change localhost to -> 127.0.0.1 !
```
[SQL]
host = 127.0.0.1
user = root
password =
dbname = yourdatabase
```

EasyCRUD
============================
The easyCRUD is a class which you can use to easily execute basic SQL operations like(insert, update, select, delete) on your database.
It uses the database class I've created to execute the SQL queries.

Actually it's just a little ORM class.

## How to use easyCRUD
#### 1. First, create a new class. Then require the easyCRUD class.
#### 2. Extend your class to the base class Crud and add the following fields to the class.
#### Example class :
```php
<?php
require_once("easyCRUD.class.php");

class YourClass  Extends Crud {

  # The table you want to perform the database actions on
  protected $table = 'persons';

  # Primary Key of the table
  protected $pk  = 'id';

}
```

## EasyCRUD in action.

#### Creating a new person
```php
<?php
// First we"ll have create the instance of the class
$person = new person();

// Create new person
$person->Firstname  = "Kona";
$person->Age        = "20";
$person->Sex        = "F";
$created            = $person->Create();

//  Or give the bindings to the constructor
$person  = new person(array("Firstname"=>"Kona","age"=>"20","sex"=>"F"));
$created = $person->Create();

// SQL Equivalent
"INSERT INTO persons (Firstname,Age,Sex) VALUES ('Kona','20','F')"
```
#### Deleting a person
```php
<?php
// Delete person
$person->Id  = "17";
$deleted     = $person->Delete();

// Shorthand method, give id as parameter
$deleted     = $person->Delete(17);

// SQL Equivalent
"DELETE FROM persons WHERE Id = 17 LIMIT 1"
```
#### Saving person's data
```php
<?php
// Update personal data
$person->Firstname = "John";
$person->Age  = "20";
$person->Sex = "F";
$person->Id  = "4";
// Returns affected rows
$saved = $person->Save();

//  Or give the bindings to the constructor
$person = new person(array("Firstname"=>"John","age"=>"20","sex"=>"F","Id"=>"4"));
$saved = $person->Save();

// SQL Equivalent
"UPDATE persons SET Firstname = 'John',Age = 20, Sex = 'F' WHERE Id= 4"
```
#### Finding a person
```php
<?php
// Find person
$person->Id = "1";
$person->find();

echo $person->Firstname;
// Johny

// Shorthand method, give id as parameter
$person->find(1);

// SQL Equivalent
"SELECT * FROM persons WHERE Id = 1"
```
#### Getting all the persons
```php
<?php
// Finding all person
$persons = $person->all();

// SQL Equivalent
"SELECT * FROM persons
```

Tuesday, 21 June 2016

PHP-MYSQLI Framework/Library For PHP application Development


A lot of Frameworks are available in PHP like cakephp,laravel,symfony,wordpress,joomla,drupal.etc. But all of them have their own restrictions, you cannot query it like what u want. Because they have their own canvas & u have to study their canvas structure to actually develop something in it. But for small application & websites you do not want to  use advanced heavy frameworks. For these type of small projects, you can use corephp frameworks.

By considering this, I have developed a  PHP-MYSQLI object oreiented  framework. Here You can query as you want, If you dont want to query also, Just use framworks methods, it is very simple...

Just Download framework from here...

Download From Here: https://github.com/litto/PHP-MYSQLI-Framework.git

The Project has 3 main Folders named- core,models,lib.
In core folder  MYSQLI & DB object Library class is situated... Here You dont want to change anything... This is the actual  core of our framework...
Next is  Models folder, It is actually files describing about the tables & their fields... In it we can describe how many fields the table has, that table has any relation with other tables.etc...
Include mysqlidb and dbObject classes. If you want to use model autoloading instead of manually including them in the scripts use autoload() method.

require_once("libs/MysqliDb.php");
require_once("libs/dbObject.php");

// db instance
$db = new Mysqlidb('localhost', 'user', '', 'testdb');
// enable class autoloading
dbObject::autoload("models");
Each database table could be easily mapped into a dbObject instance. If you do not want to create model for a simple table its object could be simply created with a table() method.

$user = dbObject::table("users");
Otherwise basic model should be declared as:

class user extends dbObject {}
In case autoload is set to 'models' directory, the filename should be models/user.php

Class will be related to 'user' table. To change the table name, define correct name in the $dbTable variable:

    protected $dbTable = "users";
Both objects created throw new class file creation of with table() method will have the same set of methods available. Only exception is that relations, validation or custom model methods will not be working with an objects created with table() method.

Third folder is lib folder.. In it you can create classes, but make sure that its name should not be same as any model names placed in model directory.. The benefit of creating files in it is that, you can write simple query's you want instead of using frameworks default functions..

Then in the rootfolder you can see a file named config, in this file only we are  describing the connection parameters named database name,username,password.etc...

Please download the files from above & just install it & see the structure . I have created list file, Create file, Edit file, delete file.etc., Database can be seen in db folder. Just import in your sql database & see its working or not?. So you can easily remember the structure... If you have any doubt please contact me....

Sunday, 7 February 2016

Installing PHP Pear Packages & Mail in Linux

In Linux we can setup Pear Packages & can directly send mail via SMTP & IMAP protocols.
First I will explain how to install Pear Packages in Linux.
Open Terminal, then type the following lines;-

sudo apt-get install php-pear
sudo pear install mail
sudo pear install Net_SMTP
sudo pear install Auth_SASL
sudo pear install mail_mime

Actually this will only download the required packages & store in a folder. So we have to execute it by typing the code below.

sudo gunzip /build/php5-0LI9sl/php5-5.5.9+dfsg/pear-build-download/*.tar
sudo pear upgrade /build/php5-0LI9sl/php5-5.5.9+dfsg/pear-build-download/*.tar

Here Location will be different for different installation, so you just replace the location depend on your installation
Now just restart the apache server
sudo service apache2 restart

Next step is to install Imap package.Type below in the terminal
sudo apt-get install php5-imap
sudo php5enmod imap
sudo service apache2 restart

Now check..everything will work Perfectly..

Changing The root mysql Password in Linux

Unlike windows, In linux its mandatory to give Mysql root password,otherwise it will not allow us to enter into the database. I will explain step by step on how to do this.

1) Stop the running Mysql process. It by typing following command in the Terminal.
sudo /etc/init.d/mysql stop

2)Connect to Mysql server without password. For this type the following in the terminal.
sudo mysqld_safe --skip-grant-tables &

3)Connect to mysql user using mysql client

sudo mysql -u root

4) Now you will enter into mysql inter face, type following in the terminal
use mysql;
update user set password=PASSWORD("NEW-ROOT-PASSWORD") where user='root';
flush privilages;
quit

5) stop Mysql server

sudo /etc/init.d/mysql stop


6) Now start the Mysql server and test it
sudo /etc/init.d/mysql start
mysql -u root -p

Setting up PHP Mysql in Linux

We are familiar with WAMP in windows for running PHP applications. Like wise it is Known as LAMP in Linux. LAMP stands for Linux Apache Mysql PHP

Below I will show step by step  instruction on how to install it.

1) First step is we have to install Apache. For this :-
Open Terminal(Applications->Accessories->Terminal)

sudo apt-get install apache2

Then it will ask you for password & type enter.

2) Test whether it is installed correctly or not. For this type http://localhost in the browser url. It will give a page if its correctly installed.

3) Next step is to install PHP. For this type the following in the Terminal & press enter

sudo apt-get install php5 libapache2-mod-php5

4) Now restart apache to make php compatible with apache. Type the following in terminal & press enter

sudo /etc/init.d/apache2 restart

5) Next step is to install Mysql. For this Type following in the terminal & press enter
sudo apt-get install mysql-server


6) Next step is to instal;l PHPmyadmin, which is an easy tool to edit our databases. For this type the following in terminal & press enter
sudo apt-get install libapache2-mod-auth-mysql  php5-mysql  phpmyadmin

7) Next step is to make mysql work with PHP , for this we have to open PHP configuration file and enable mysql extension in it.
gksudo gedit /etc/php5/apache2/php.ini

Find the Line
;extension=mysql.so   
Remove the semicolon which will look like this
extension =mysql.so

8) Now Just restart the apache
sudo /etc/init.d/apache2 restart

9) Now check if its working by typing localhost/phpmyadmin in your browser. if its giving error then
we have to edit apache2.config file .Type following Line & press enter
sudo gedit /etc/apache2/apache2.conf

Include the following line in the bottom of the page..

Include /etc/phpmyadmin/apache.conf


10) Now Just restart apache & check..

sudo /etc/init.d/apache2 restart

To find out strict mode status, run the below sql

SHOW VARIABLES LIKE 'sql_mode';

If the output value contains STRICT_TRANS_TABLES, then strict mode is enabled.

To disable strict mode, run the below sql

SET GLOBAL sql_mode = '';

To enable strict mode, run the below sql

SET GLOBAL sql_mode = 'STRICT_TRANS_TABLES';

 


Now Everything will be working fine... Enjoy...



Installing Symfony in Windows

Symfony-The leading PHP framework to create websites and web applications. Built on top of the Symfony Components. Installation of symfony is slightly different from PHP's other frameworks. I will explain you step by step on how to set up your first Symfony application running in your windows PC.
1) Firstly make sure that curl is installed in your computer. If not then download it from here
Then Extract the folder & copy all the contents & paste it into the C:/Windows/System32 Folder.

2) Now its time to install Symfony. First open the Command prompt (type run insearch.,In it type cmd & press enter). Open it in administrator mode.

3) In the command prompt window just type
php -r "readfile('https://symfony.com/installer');" > symfony

2) Now symfony installation file will be automatically downloaded into your system.Now its time to move the downloded file to the working folder. For this type in the cmd like shown below , second argument will be location of the project. After that enter into the directory By typing cd & then executing PHP command.

3) Now its time to create the application. Now enter into the directory type the following command
php new my_project

4) To run the application, Enter into the project folder from cmd & then type
php app/console server:run
5) The  inorder to view our application go to the browser & type
localhost:8000/
6) To stop the application run,type following in the cmd
php app/console server;stop


c:\> move symfony c:\wamp\www\myapps\
c:\> cd wamp
c:\wamp> cd www
c:\wamp\www>cd myapps
c:\wamp\www\myapps\> php symfony  
c:\wamp\www\myapps\> php new my_project_name   /* project will be created*/
c:\wamp\www\myapps\> cd my_project_name        /*Navigate to project Directory */    
c:\wamp\www\myapps\my_project_name\> php app/console server:run  /* Running the application */