Saturday, 27 August 2011

jQuery.noConflict() → jQuery

This helps to make sure that jQuery doesn't conflict with the $ object of other libraries. By using this function, you will only be able to access jQuery using the 'jQuery' variable. For example, where you used to do $("div p"), you now must do jQuery("div p").

Example:
Maps the original object that was referenced by $ back to $.
jQuery.noConflict();
// Do something with jQuery
jQuery("div p").hide();
// Do something with another library's $()
$("content").style.display = 'none';
Example:
Reverts the $ alias and then creates and executes a function to provide the $ as a jQuery alias inside the functions scope. Inside the function the original $ object is not available. This works well for most plugins that don't rely on any other library.
jQuery.noConflict();
(function($) {
$(function() {
// more code using $ as alias to jQuery
});
})(jQuery);
// other code using $ as an alias to the other library
Example:
Creates a different alias instead of jQuery to use in the rest of the script.
var j = jQuery.noConflict();
// Do something with jQuery
j("div p").hide();
// Do something with another library's $()
$("content").style.display = 'none';

How to run .exe file in asp.net?

Steps to Access the .exe files using .net:

1). Import the below class in your file:
using System.Diagnostics;
2). Write this code on button_click event--
Process p = new Process();
p.StartInfo.FileName="c:\\windows\notepad.exe";
p.Start();

How To Install And Configure Wibiya Web Toolbar For WordPres

Friday, 26 August 2011

MySQL Alter Table Add Column Command

Alter Table command is used for modifying the structure of the table. Means to add the new column, drop the column etc.

ADD COLUMN:
Syntax:
ALTER TABLE table_name ADD COLUMN column_name column-definition [ FIRST | AFTER col_name ]
Note: We can use both ADD COLUMN or ADD for adding the column.

Example 1:
ALTER TABLE student ADD COLUMN st_phone varchar(12) NOT NULL, st_gender varchar(5) NOT NULL;

Example 3:
ALTER TABLE student ADD COLUMN st_phone varchar(12) NOT NULL AFTER st_mobile,ADD COLUMN st_gender varchar(5) NOT NULL AFTER st_name,ADD COLUMN st_id int FIRST;

Example 4:
ALTER TABLE student ADD (st_phone varchar(100), st_email varchar(200),st_address varchar(200));

Example 5:
ALTER TABLE student ADD COLUMN st_phone varchar(12) DEFAULT NULL;

Example 6:
ALTER TABLE student ADD COLUMN st_id int NOT NULL AUTO_INCREMENT PRIMARY KEY;

MySQL Create Table Commands

Create Table command is used for creating tables in mysql.

Syntax 1:
CREATE TABLE [IF NOT EXISTS] table_name(
column_name1 type(size) constraints,
column_name2 type(size) constraints,
------------------------------------
------------------------------------
);

Constraints of tables: NOT NULL, AUTO_INCREMENT, PRIMARY KEY,UNIQUE
Note: The sequence of Constraints will be : NOT NULL, AUTO_INCREMENT, PRIMARY KEY,UNIQUE

Example:
CREATE TABLE student(
st_id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
st_name varchar(200),
st_father varchar(200) NOT NULL
);

Syntax 2:
CREATE TABLE table_name(
column_name1 type(size) constraints,
column_name2 type(size) constraints,
------------------------------------
------------------------------------
column_name2 type(size) constraints,
PRIMARY KEY(column_name)
);

Example:
CREATE TABLE student(
st_id int(11) NOT NULL AUTO_INCREMENT,
st_name varchar(200),
st_father varchar(200) NOT NULL, PRIMARY KEY(st_id)
);

Syntax 3:
CREATE TABLE table_name SELECT column1,column2,column3 FROM table_name WHERE condition;

Note 1: The above syntax will create the backup of existing table, with the data structure and contents.

Note 2: The above command will not copy auto incremented fields and the primary key constraints.

Example:
CREATE TABLE student_backup SELECT * FROM student;

Show the structure of the table:

Syntax 1: DESC table_name;
Example: DESC student;

Syntax 2: EXPLAIN table_name;
Example: EXPLAIN student;

Syntax 3: EXPLAIN table_name;
Example: EXPLAIN student;

Note: EXPLAIN, DESC, DESCRIBE works as same way.

Syntax 4: SHOW CREATE TABLE table_name;
Example: SHOW CREATE TABLE student;

How to connect MySQL with Java?

Steps to Connnect the MySQL with JDBC:
------------------------------------------
1). Download MySQL database.
2). Install it.
3). Download the mysql-connector-java-5.1.10, it depends on your JDBC version
4). It is a type 4 driver.
5). Extract the mysql-connector-java-5.1.10 and copy the "mysql-connector-java-[version]-bin-g.jar" into such location where you can find it easily.
6). Now set the "CLASSPATH" for that jar file.
7). Copy the code and paste it to your file:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class MySQLCon {

public static void main(String args[]) {
Connection con = null;

try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql:///DATABASE NAME","root", "");

if(!con.isClosed())
System.out.println("Successfully connected to MySQL server using TCP/IP...");

} catch(Exception e) {
System.err.println("Exception: " + e.getMessage());
} finally {
try {
if(con != null)
con.close();
} catch(SQLException e) {}
}
}
}

8). Provide the Database Name and the credentials of the MySQL.
9). Compile it and run it.

How to Connect MySQL with Java?

Thursday, 25 August 2011

How to Setup Google DNS on your Computer

DNS settings are specified in the TCP/IP Properties window for the selected network connection.
1. Go the Control Panel.
2. Click Network Connection, and click Change adapter settings
3. Select the connection for which you want to configure Google Public DNS.
For example:
o To change the settings for an Ethernet connection, right-click Local Area Connection, and click Properties.
o To change the settings for a wireless connection, right-click Wireless Network Connection, and click Properties.

4. Select the Internet Protocol/TCP/IP tab. and then click Properties
5. Click Advanced and select the DNS tab. If there are any DNS server IP addresses listed there, write them down for future reference, and remove them from this window.
6. Click OK.
7. Select Use the following DNS server addresses. If there are any IP addresses listed in the Preferred DNS server or Alternate DNS server, write them down for future reference.
8. Replace those addresses with the IP addresses of the Google DNS servers: 8.8.8.8 and 8.8.4.4.
9. Restart the connection you selected

Wednesday, 24 August 2011

Five Ways to Take Input in Java

Program 1: import java.io.*;
public class Program1
{
public static void main(String ar[])
{
int a,b,c;
DataInputStream ds=new DataInputStream(System.in);
try
{
System.out.printf("Enter the number : ");
a=Integer.parseInt(ds.readLine());
System.out.printf("Enter the number : ");
b=Integer.parseInt(ds.readLine());
c=a+b;
System.out.format("The sum of %d and %d is %d",a,b,c);
}
catch(Exception e)
{
}
}
}

Program 2:
import java.io.*;
public class Program2
{
public static void main(String ar[])throws IOException
{
int a,b,c;
InputStreamReader str=new InputStreamReader(System.in);
BufferedReader bfr=new BufferedReader(str);
System.out.printf("Enter the number : ");
a=Integer.parseInt(bfr.readLine());
System.out.printf("Enter the number : ");
b=Integer.parseInt(bfr.readLine());
c=a+b;
System.out.format("The sum of %d and %d is %d",a,b,c);
}
}

Program 3:
import java.io.*;
public class Program3
{
public static void main(String ar[])throws IOException
{
int a,b,c;
DataInputStream ds=new DataInputStream(System.in);
System.out.printf("Enter te number : ");
a=Integer.parseInt(ds.readLine());
System.out.printf("Enter the number : ");
b=Integer.parseInt(ds.readLine());
c=a+b;
System.out.format("The sum of %d and %d is %d",a,b,c);
}
}

Program 4:
import java.util.*;
public class Program4
{
public static void main(String ar[])
{
Scanner sc=new Scanner(System.in);
int a;
String str=new String();
float f;
System.out.print("Enter the integer value : ");
a=sc.nextInt();
System.out.print("Enter the String value : ");
str=sc.nextLine();
System.out.print("Enter the float value : ");
f=sc.nextFloat();
System.out.printf("The value 0f integer is %d \nThe value of float is %f\n The value of string is %s",a,f,str);
}
}

Program 5:
import javax.swing.*;
public class Program5
{
public static void main(String[] args)
{
String a;
a=JOptionPane.showInputDialog(null, "Enter some text : ");
JOptionPane.showMessageDialog(null,a);
}
}

MySQL User Management Commands

To create a user in MySQL:
CREATE USER 'user_name'@'hostname' IDENTIFIED BY 'password';

Note:All the users of MySQL are stored in the MySQL database inside the user table.

Example 1:
Create a user kaushal on localhost with password test:
CREATE USER 'kaushal'@'localhost' IDENTIFIED BY 'test'

Create a user kishore without password:
CREATE USER 'kishore'@'localhost';

To delete the user:
DROP USER 'username'@'localhost';

Example: DROP USER 'kishore'@'localhost';

To Rename the User:
RENAME USER 'username'@'hostname' TO 'username'@'hostname';

Example: RENAME USER 'kaushal'@'localhost' TO 'iics'@'localhost';

To show all the users of MySQL:
SELECT user FROM mysql.user;

To show User,Password,host of MySQL:
SELECT user,host,password FROM mysql.user;

Note:All the user information such as Hostname, username, password and its privileges for all databases are stored in “mysql” database inside the “user” table.

To reset the password for specific user:
SET PASSWORD FOR 'username'@'hostname' = PASSWORD('newpassword');

Example: SET PASSWORD FOR 'iics'@'localhost' = PASSWORD('hello');

Syntax 2:  UPDATE mysql.user SET password = PASSWORD('test') WHERE user='iics' AND host='localhost';

MySQL Basic Command List

Command for Create the database:
CREATE DATABASE database_name;
CREATE SCHEMA database_name;

Command For Creating The Database IF DATABASE NOT EXIST:

CREATE DATABASE IF NOT EXISTS database_name;
CREATE SCHEMA IF NOT EXISTS database_name;

To show the database:
SHOW DATABASES;

To show the particular database:
SHOW DATABASES LIKE “%search_text%”

To Delete the Database:
DROP DATABASE database_name;

To Delete the DATABASE if database available:
DROP DATABASE IF EXISTS database_name;

To select the database or change the database:
USE database_name;

To show all the tables of database:
SHOW TABLES;

To show the specific tables from database:
SHOW TABLES LIKE '%search_text%'

To show tables from another database:
SHOW TABLES FROM database_name;

For searching:
SHOW TABLES FROM database_name LIKE “%search_text%”;

To describe the table:
DESCRIBE table_name;

To show the create syntax of the Database:
SHOW CREATE DATABASE database_name;

To List all the Character Set of the MySQL:
SHOW CHARACTER SET;

Note: Character set shows the type of the character, which are storing in the database. Such as chinees, european, swidish, latin, arabic etc.

To show the sytax of create table:
SHOW CREATE TABLE table_name;

Show all the columns and the type of the table:
SHOW COLUMNS FROM table_name;

Note: It works just like a DESCRIBE table_name;

Show all the Open Tables and its status:
SHOW OPEN TABLES;

Show the error generated by Query and other operations:
SHOW ERRORS;

Note : It show the Error number and description also.

Count the number of Errors:
SHOW COUNT(*) ERRORS;
SELECT COUNT(*) ERRORS;
SELECT @@error_count;

Show all the warnings:
SHOW WARNINGS;

To Count the warnings:
SELECT COUNT(*) WARNINGS;
SHOW COUNT(*) WARNINGS;
SELECT @@warning_count;

Note: warning_count is the variable of MySQL and we can use the variable of MySQL using the “@@” symbol. Show the syntax is:

Syntax:
@@variable_name;

To show the Privileges of the current login user:
SHOW PRIVILEGES;

Note: It will display all the privileges of the current login user means that what type of operation he can be done. Some examples of privileges are ALTER, UPDATE, DROP, CREATE, DELETE etc.

To show all the Processlist:
SHOW PROCESSLIST;

Note: It will display all the process, users, states and the database which are currently running.

To show all the indexes of the tables:
1).
SHOW INDEX FROM table_name;
SHOW INDEX FROM student;

2).
SHOW INDEX FROM table_name FROM database_name;
SHOW INDEX FROM student FROM school;

3).
SHOW INDEX FROM database_name.table_name;
SHOW INDEX FROM school.student;

SHOW all the columns or fields name of the table:
1).
SHOW COLUMNS FROM table_name
SHOW COLUMNS FROM table_name FROM database_name;
SHOW COLUMNS FROM database_name.tablename;

2).
SHOW FIELDS FROM table_name;
SHOW FIELDS FROM table_name FROM database_name;
SHOW FIELDS FROM database_name.tablename;

3). DESC table_name;
4). DESCRIBE table_name;

To show all the database engines of MySQL:
1). SHOW ENGINES;
2). SHOW STORAGE ENGINES;
3). SHOW TABLE TYPES;

To show the status of any Engine:
SHOW ENGINE engine_name STATUS;
Example:
SHOW ENGINE INNODB STATUS;

To show the Logs for any Engine:
SHOW ENGINE engine_name LOGS;
Example:
SHOW ENGINE INNODB LOGS;

To Status of the tables of databse:
SHOW TABLE STATUS;

Note: It displays all the data of the table structure with advance options.

MySQL Revoke Command Syntax And Example

The opposite of GRANT is REVOKE. It is used to take privileges away from a user. It is very similar to GRANT in syntax. The REVOKE command is used to rescind privileges previously granted to a user.
Syntax:
REVOKE priv_type [(column_list)] [, priv_type [(column_list)] ...]
ON {tbl_name | * | *.* | db_name.*}
FROM user_name [, user_name …]

To revoke the SELECT persmission from the “payroll” database:
REVOKE SELECT ON payroll.* FROM 'iics'@'localhost';

To revoke the DELETE persmission from the “student” table from “school” database:
REVOKE DELETE ON school.student FROM 'iics'@'localhost';

To revoke the ALL privileges from the “school” database:
REVOKE ALL PRIVILEGES ON school.* FROM 'kaushal'@'localhost';

To revoke the all privileges from the “hospital” database:
REVOKE ALL ON hospital.* FROM 'iics'@'localhost';

To revoke MULTIPLE Privileges to all tables of customer database:
REVOKE SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON customer.* FROM 'iics'@'localhost';

To revoke the all privileges from the all databases and tables:
REVOKE ALL ON *.* FROM 'iics'@'localhost';

To Revoke INSERT,SELECT Privileges to specific columns of the tables:
REVOKE SELECT (col1), INSERT (col1,col2) ON mydb.mytbl TO 'iics'@'localhost';

MySQL Grant Command Syntax and Examples

To Give all the permission to iics user to school database:
GRANT ALL ON school.* TO 'iics'@'localhost';

Give the SELECT Privileges to “invoice” table of “db2” database:
GRANT SELECT ON db2.invoice TO 'iics'@'localhost';

Give the USAGE Privileges to all database and tables:
GRANT USAGE ON *.* TO 'iics'@'localhost';

Give All the Privileges to all database and tables:
GRANT ALL ON *.* TO 'iics'@'localhost';

Give INSERT,SELECT Privileges to all database and tables:
GRANT SELECT, INSERT ON *.* TO 'iics'@'localhost';

Give INSERT,SELECT Privileges to specific database and tables:
GRANT SELECT, INSERT ON mydb.* TO 'iics'@'localhost';

Give INSERT,SELECT Privileges to specific columns of the tables:
GRANT SELECT (col1), INSERT (col1,col2) ON mydb.mytbl TO 'iics'@'localhost';

Give ALL Privileges to all database and tables with new password:
GRANT ALL PRIVILEGES ON *.* TO db_user @'%' IDENTIFIED BY 'db_passwd';

Give MULTIPLE Privileges to all tables of customer database:
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON customer.* TO 'custom'@'localhost';

To Show all the GRANT Permissions to Current Login User:
SHOW GRANTS;
SHOW GRANTS FOR CURRENT_USER;
SHOW GRANTS FOR CURRENT_USER();


To Show all the GRANT Permissions for specific user:
SHOW GRANTS FOR 'iics'@'localhost';

To list all the privileges supported by MySQL:
SHOW PRIVILEGES;

To flush all the privileges:
FLUSH PRIVILEGES;

How to break a string into an array in PHP?

There are two method used to break a string in to an array:

  1. split(): split() can break string in an array by given string separator or given regular expression.

  2. explode(): explode() function can only break the string by given separator.


 

What is the use of unlink(), unset() inPHP?

unlink():- This is used to delete the file from given location and file name

unset():- by using unset() function we can remove or reset the variable value.

How to set the hide extension for known file type in Windows 7

Step 1:- First Open My Computer
Step 2:- Open any Drive
Step 3:- Pres Alt+T
Step 4:- Menu Bar will activate
Step 5:- Select Tools Menu
Step 6:- Click on Folder Option
Step 7:- Select View Tab
Step 8:- Uncheck the hide extension for known file types.
Step 9:- Click on Apply Button
Step 10:- Now click on Ok Button. Now setting will apply.

What is date() function in PHP?

 date() function is used to display the date, time, and month according to given format.

e.g echo date(“d/m/y”);  // output: 29/5/2011

d- date

D- day name

m- month

M- month name

y- sort year like 2011 as 11

Y-full year like 2011

h- hours

i- minute

s- second

How to set the hide extension for known file in Windows 7

Tuesday, 23 August 2011

Difference Between mysql_connect() and mysql_pconnect()

mysql_connect() and mysql_pconnect() both are working for database connection but with little difference. In mysql_pconnect(), ‘p’ stands for persistance connection.

When we are using mysql_connect() function, every time it is opening and closing the database connection, depending on the request .

But in case of mysql_pconnect() function,
First, when connecting, the function would try to find a (persistent) connection that’s already open with the same host, username and password. If one is found, an identifier for it will be returned instead of opening a new connection.
Second, the connection to the SQL server will not be closed when the execution of the script ends. Instead, the connection will remain open for future use (mysql_close() will not close connection established by mysql_pconnect()).

mysql_pconncet() is useful when you have a lot of traffice on your site. At that time for every request it will not open a connection but will take it from the pool. This will increase the efficiency of your site. But for general use mysql_connect() is best.

I think this is a very imp concept in case of Database Connectivity.

MySQLAdmin Command

mysqladmin is a client for performing administrative operations.
You can use it to check the server’s configuration and current status,
create and drop databases, and more.

Check whether MySQL Server is up and running?
mysqladmin -u root -p ping
Find out what version of MySQL I am running
mysqladmin -u root -proot version
Current status of MySQL server
mysqladmin -u root -proot status
Variable Names and Description:
Uptime: Uptime of the mysql server in seconds
Threads: Total number of clients connected to the server.
Questions: Total number of queries the server has executed since the startup.
Slow queries: Total number of queries whose execution time was more than long_query_time variable’s value.
Opens: Total number of tables opened by the server.
Flush tables: How many times the tables were flushed.
Open tables: Total number of open tables in the database.

View all the MySQL Server status variable and it's current value
mysqladmin -u root -proot extended-status
To display all MySQL server system variables and the values
mysqladmin -u root -proot variables
To display all the running process/queries in the mysql database
mysqladmin -u root -proot processlist
Create a MySQL Database
mysqladmin -u root -proot create testdb
Delete/Drop an existing MySQL database
mysqladmin -u root -proot DROP testdb
Reload/refresh the privilege or the grants tables
mysqladmin -u root -proot reload
mysqladmin -u root -proot refresh
Shutdown the MySQL Server:
mysqladmin -u root -proot shutdown
Kill a hanging MySQL Client Process
mysqladmin -u root -proot kill processID

Note: In above examples, -proot,-p represents the password of the mysqladmin server and there should not be space between -p and password.

Monday, 22 August 2011

How to Connect PHP with MS-Access?

I have been trying to connect Ms Access using PHP for couples of days. Finally I have done it. It was dome using Open DataBase Connectivity, popularly known as ODBC (pronounced as separate letters). With an ODBC connection, you can connect to any database, on any computer in your network, as long as an ODBC connection is available. 

Here is how to create an ODBC connection to a MS Access Database:
Open the Administrative Tools icon in your Control Panel.
Double-click on the Data Sources (ODBC) icon inside.
Choose the System DSN tab.
Click on Add in the System DSN tab.
Select the Microsoft Access Driver. Click Finish.
In the next screen, click Select to locate the database.
Give the database a Data Source Name (DSN).
Click OK.
Note that this configuration has to be done on the computer where your web site is located. If you are running Internet Information Server (IIS) on your own computer, the instructions above will work, but if your web site is located on a remote server, you have to have physical access to that server, or ask your web host to to set up a DSN for you to use.

Connecting to an ODBC
The odbc_connect() function is used to connect to an ODBC data source. The function takes four parameters: the data source name, username, password, and an optional cursor type.
The odbc_exec() function is used to execute an SQL statement.

Example
The following example creates a connection to a DSN called northwind, with no username and no password. It then creates an SQL and executes it:
$conn=odbc_connect('northwind','','');
$sql="SELECT * FROM customers";
$rs=odbc_exec($conn,$sql);

Retrieving Records
The odbc_fetch_rows() function is used to return records from the result-set. This function returns true if it is able to return rows, otherwise false.
The function takes two parameters: the ODBC result identifier and an optional row number:
odbc_fetch_row($rs)

Retrieving Fields from a Record
The odbc_result() function is used to read fields from a record. This function takes two parameters: the ODBC result identifier and a field number or name.
The code line below returns the value of the first field from the record:
$compname=odbc_result($rs,1);
The code line below returns the value of a field called "CompanyName":
$compname=odbc_result($rs,"CompanyName");

Closing an ODBC Connection
The odbc_close() function is used to close an ODBC connection.
odbc_close($conn);

An ODBC Example
The following example shows how to first create a database connection, then a result-set, and then display the data in an HTML table.
<html>
<body><?php
$conn=odbc_connect('northwind','','');
if (!$conn)
{exit("Connection Failed: " . $conn);}
$sql="SELECT * FROM customers";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{exit("Error in SQL");}
echo "<table><tr>";
echo "<th>Companyname</th>";
echo "<th>Contactname</th></tr>";
while (odbc_fetch_row($rs))
{
$compname=odbc_result($rs,"CompanyName");
$conname=odbc_result($rs,"ContactName");
echo "<tr><td>$compname</td>";
echo "<td>$conname</td></tr>";
}
odbc_close($conn);
echo "</table>";
?></body>
</html>

How to connect PHP with MS-Access?

I have been trying to connect Ms Access using PHP for couples of days. Finally I have done it. It was dome using Open DataBase Connectivity, popularly known as ODBC (pronounced as separate letters). With an ODBC connection, you can connect to any database, on any computer in your network, as long as an ODBC connection is available. 

Here is how to create an ODBC connection to a MS Access Database:

Open the Administrative Tools icon in your Control Panel.
Double-click on the Data Sources (ODBC) icon inside.
Choose the System DSN tab.
Click on Add in the System DSN tab.
Select the Microsoft Access Driver. Click Finish.
In the next screen, click Select to locate the database.
Give the database a Data Source Name (DSN).
Click OK.
Note that this configuration has to be done on the computer where your web site is located. If you are running Internet Information Server (IIS) on your own computer, the instructions above will work, but if your web site is located on a remote server, you have to have physical access to that server, or ask your web host to to set up a DSN for you to use.

--------------------------------------------------------------------------------
Connecting to an ODBC
The odbc_connect() function is used to connect to an ODBC data source. The function takes four parameters: the data source name, username, password, and an optional cursor type.

The odbc_exec() function is used to execute an SQL statement.

Example
The following example creates a connection to a DSN called northwind, with no username and no password. It then creates an SQL and executes it:
$conn=odbc_connect('northwind','','');
$sql="SELECT * FROM customers";
$rs=odbc_exec($conn,$sql);

--------------------------------------------------------------------------------

Retrieving Records
The odbc_fetch_rows() function is used to return records from the result-set. This function returns true if it is able to return rows, otherwise false.

The function takes two parameters: the ODBC result identifier and an optional row number:

odbc_fetch_row($rs)


--------------------------------------------------------------------------------

Retrieving Fields from a Record
The odbc_result() function is used to read fields from a record. This function takes two parameters: the ODBC result identifier and a field number or name.

The code line below returns the value of the first field from the record:

$compname=odbc_result($rs,1);

The code line below returns the value of a field called "CompanyName":

$compname=odbc_result($rs,"CompanyName");


--------------------------------------------------------------------------------

Closing an ODBC Connection
The odbc_close() function is used to close an ODBC connection.

odbc_close($conn);


--------------------------------------------------------------------------------

An ODBC Example
The following example shows how to first create a database connection, then a result-set, and then display the data in an HTML table.

<html>
<body><?php
$conn=odbc_connect('northwind','','');
if (!$conn)
{exit("Connection Failed: " . $conn);}
$sql="SELECT * FROM customers";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{exit("Error in SQL");}
echo "<table><tr>";
echo "<th>Companyname</th>";
echo "<th>Contactname</th></tr>";
while (odbc_fetch_row($rs))
{
$compname=odbc_result($rs,"CompanyName");
$conname=odbc_result($rs,"ContactName");
echo "<tr><td>$compname</td>";
echo "<td>$conname</td></tr>";
}
odbc_close($conn);
echo "</table>";
?></body>
</html>

DC SHOES: KEN BLOCK'S GYMKHANA FOUR; THE HOLLYWOOD MEGAMERCIAL

How to run Java Program in windows7







Installing Java

You will use the Java compiler javac to compile your Java programs and the Java interpreter java to run them. You should skip the first step if Java is already installed on your machine.

  • Download and install the latest version of the Java Platform, Standard Edition Development Kit (JDK 6 Update 23). Note the installation directory for later—probably something likeC:\Program Files\Java\jdk1.6.0_23\bin.

  • To make sure that Windows can find the Java compiler and interpreter:

    • Select Start -> Computer -> System Properties -> Advanced system settings -> Environment Variables -> System variables -> PATH.[ In Vista, select Start -> My Computer -> Properties -> Advanced -> Environment Variables -> System variables -> PATH. ][ In Windows XP, Select Start -> Control Panel -> System -> Advanced -> Environment Variables -> System variables -> PATH. ]

    • Prepend C:\Program Files\Java\jdk1.6.0_23\bin; to the beginning of the PATH variable.

    • Click OK three times.










Command-line interface

You will type commands in an application called the Command Prompt.

  • Launch the command prompt via All Programs -> Accessories -> Command Prompt. (If you already had a command prompt window open, close it and launch a new one.) You should see the command prompt; it will look something like:

    Microsoft Windows [Version 6.1.7600]
    Copyright (c) 2009 Microsoft Corporation. All rights reserved.



  • To check that you have the right version of Java installed, type the text in boldface below. You should see something similar to the information printed below. (It's important that you see the number 1.6 or 1.5 for the Java version number, but the rest is not critical.)

    C:\Users\username>java -version
    java version "1.6.0_23"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0_23-b07)
    Java HotSpot(TM) Client VM (build 1.6.0_23-b13, mixed mode, sharing)


    Then type:

    C:\Users\username>javac -version
    javac 1.6.0_23



  • Since you will be using the Command Prompt frequently, we recommend customizing the default settings. Right-click the title bar of an open Command Prompt window, select Properties and then:

    • Set Layout -> Screen Buffer Size to 80 x 500.

    • Select Options -> Edit Options -> QuickEdit Mode.

    • Select Options -> Edit Options -> Insert Mode.










Compile the Program

You will use the javac command to convert your Java program into a form more amenable for execution on a computer.

  • From the Command Prompt, navigate to the directory containing your .java files, say C:\introcs\hello, by typing the cd command below.

    C:\Users\username>cd c:\introcs\hello
    C:\introcs\hello\>



  • Assuming the file, say HelloWorld.java, is in the current working directory, type the javac command in boldface below to compile it.

    C:\introcs\hello\>javac HelloWorld.java
    C:\introcs\hello\>


    If everything went well, you should see no error messages.








Execute the Program

You will use the java command to execute your program.

  • From the Command Prompt, type the java command below.

    C:\introcs\hello\>java HelloWorld
    Hello, World


    If all goes well, you should see the output of the program - Hello, World.








Input and Output

If your program gets stuck in an infinite loop, type Ctrl-c to break out.

If you are entering input from the keyboard, you can signify to your program that there is no more data by typing Ctrl-z for EOF (end of file). On some DOS systems the first line of output sent to the screen after you enter EOF will be rendered invisible by DOS. This is not a problem with your code, but rather a problem with DOS. To help you debug your program, we recommend including an extra System.out.println(); statement before what you really want to print out. If anyone knows of a better fix, please let us know!






Troubleshooting

Here are a few suggestions that might help correct any installation woes you are experiencing. If you need assistance, don't hesitate to contact a staff member.

When I type, "java -version" I get an error. Check that you edited your PATH environment variable as indicated. A missing ; or an added % is enough to screw things up. Close and re-open a command prompt. Type path at the command prompt and look for an entry that includes C:\Program Files\Java\jdk1.6.0_23\bin;. Check that the version number 1.6.0_23 matches the one you installed since Oracle updates Java periodically and you might have a more recent version. If this doesn't fix the problem, check if you have any old versions of Java on your system. If so, un-install them and re-install Java.

The command "java -version" works, but not "javac -version". Any thoughts? It's likely a path issue. Try the suggestions from the previous question. Also check that you installed the JDK properly by checking that the folder C:\Program Files\Java\jdk1.6.0_23\bin exists.

How can I check the values of my PATH variable? Type the following at the command prompt.

C:\introcs\hello\> echo %PATH%


The PATH variable should begin with C:\Program Files\Java\jdk1.6.0_23\bin; Be sure to open the command prompt after you have edited the PATH environment variable. You may also need to reboot for the environment variable change to take effect.

I can compile with javac, but I get the error message "Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld" when I try to execute it with java. First, be sure thatHelloWorld.class is now in the current directory. Be sure to type java HelloWorld without a trailing .class or .java. Check that the command "java -version" works. Now try to execute with "java -cp . HelloWorld". If this works, you need to edit your classpath. (iTunes has a proclivity for changing the classpath, so if you recently upgraded iTunes, this is likely the source of the problem.)

 

How to Install Wordpress?

1. Download WordPress

The very first thing you’ll want to do is download a copy of the software. So, go to the WordPress site here, and look for the link that says “DOWNLOAD.ZIP.” You should see it on the right side of the page with a dark blue background. When you see the link, click on it, and save the file to your desktop so it’s easy to find going forward.

2. Unzip the Folder

After you download the program, you’ll need to unzip the files into their own folder on your desktop. Most computers have a built-in zip/unzip application when you buy them, and if you’re not sure about your system, right-click on the file you just downloaded, and look for the menu option that says “Extract All …” Select that option if you see it. If you don’t have an unzip feature already installed, you can download a free program called Stuffit Expander (for PC or Mac).

3. Set Up Your FTP Program

FTP stands for File Transfer Protocol, and an FTP program will allow you to copy files from your own computer to your web hosting account. There are many FTP programs available, and one of the more popular ones is free program called FileZilla. You can download it here.

4. Get Your FTP Access Information

You’ll need to enter this information into your FTP program to access and upload files to your web host. Specifically, you’ll need to enter the the domain name, username and password for your FTP account. You can get this information from your web host if you don’t have it already.

5. Set Up Your MySQL Database With Your Web Host

This isn’t as scary as it may sound. Well, not if you have a good web host. You can usually find a link in your web hosting control panel to set up a MySQL database. Once the database is set up, you’ll need the database name, database password, database username and database hostname The hostname is usually “localhost,” but not always, so check with your web host to be sure. If you use Hostgator, it is localhost.

6. Enter Your Database Information into Your Config File

Remember when you downloaded and unzipped the WordPress program on your computers desktop? Open that folder, and you’ll see another folder labeled “WordPress.” Open that folder, and find a file named wp-config-sample. Open this file in a text editor such as Notepad or Wordpad. When you open the file you’ll see some text, much of which looks like gibberish, but it’s not. Look specifically for the lines that read:

// ** MySQL settings - You can get this info from your web host ** //

/** The name of the database for WordPress */
define('DB_NAME', 'putyourdbnamehere');

/** MySQL database username */
define('DB_USER', 'usernamehere');

/** MySQL database password */
define('DB_PASSWORD', 'yourpasswordhere');

/** MySQL hostname */
define('DB_HOST', 'localhost');

This is the place to enter the database information you saved from the previous step. So whatever the database name is, enter that information in place of ‘putyourdbnamehere.’ Just be sure to leave the ‘ marks before and after as it appears above. Do the same for the DB_USER, DB_PASSWORD and DB_HOST. When you’re done, save the file, but save it as wp-config.php rather than wp-config-sample.

7. Upload WordPress to Your Server

Okay. We’re in the homestretch. The next thing you want to do is upload the entire program from your computer to you host’s server. So, first, open your FTP program and connect to your host’s server. Back in step 5, you tracked down your FTP information. If you haven’t already entered it into your FTP program, go ahead and do that now. Again, you’ll need to enter you domain name, your username and your password. After you enter the information, go ahead and connect to your host’s server.

At this point, you’ll need to make a decision about where you’ll place the program. You can put it in – either – the root directory of your host server or a sub-directory. Personally, I place mine in a subdirectory because I run several different websites on the same server, and it just makes things a lot easier by keeping them separate. After you make your decision, go ahead and upload all the files and directories located in the WordPress folder you unzipped to you desktop, excluding the folder itself.

8. Run the Install Script

  • If you installed WordPress in the root directory of your server, open your web browser and type the following: http://www.mydomain.com/wp-admin/install.php (replace “mydomain.com” with your own domain name).



  • If you installed WordPress in a sub-directory, open your web browser and type the following: http://www.mydomain.com/subdirectory/wp-admin/install.php (replace “mydomain.com” with your own domain name and “subdirectory” with the name of the sub-directory you created).


After you go to this page, WordPress will do the rest. Just follow the onscreen directions, and then you’ll be all done.