Posted on 1 Comment

Best PTC Sites

Top 10 PTC sites in July 2012

1.

  • Ads: ~10 per day, click rate $0.001-$0.02.
  • Payout: Minimum $8 for standard members, to PayPal or AlertPay.
  • Online and paying since 2007.
  • Chance to win $5 every day.
  • Referrals: $0.0002-$0.008 per click. Unlimited number of referrals.

Join ClixSense Now | Site Details

2. PTCBox

  • Ads: $0.005 per click. Offers about 5 ads per day.
  • Payout: Instant to AlertPay/PayPal. Minimum $2 for free members.
  • Paid to sign up offers worth up to $100.
  • Ability to customize your own membership type.
  • Referrals: 10% for free members and up to 100% for upgraded.

Join PTC Box Now | Site Details

3. Clicksia

  • Ads: Usually around 10 per day, with a click rate of $0.003-$0.001.
  • Payout: Minimum $1 to AlertPay or PayPal.
  • Lots of easy sign up offers that pays $0.10 and up.
  • Get paid $0.0001 per hit to promote your referral URL.
  • Referrals: Earn 10% on clicks and sign up offers. Unlimited referrals.

Join Clicksia Now | Site Details

4

Incentria

  • Ads: ~10 ads per day with a click rate of $0.003-$0.001.
  • Payout: AlertPay or PayPal. Low $1 minimum for standard members.
  • Get paid $0.10-$0.50 to complete sign up offers.
  • Promote your referral URL and earn $0.0001 per valid hit.
  • Referrals. Unlimited number of referrals. Earn 10% of all earnings.

Join Incentria Now | Site Details

5

NeoBux

  • Ads: ~20 ads per day that pays $0.001-$0.015 per click.
  • Payout: Payments are instant to AlertPay or PayPal. Minimum $2.
  • Bonus points for every click – exchange for upgrades or money.
  • One of the most trusted PTC sites since 2008.
  • Referrals: $0.0005-$0.005 per referral click and 1% on purchases.

Join NeoBux Now | Site Details

6

DonkeyMails

  • Ads: Varying amount of PTC and PTR ads worth $0.001-$0.0025.
  • Payout: No minimum. AlertPay, PayPal and several other options.
  • Earn up to $25 for sign up offers. New ones added daily.
  • Get paid to promote and earn up to $0.50 per 1000 hits.
  • Referrals: 5 level referral program (earn 10%/5%/3%/2%/1%)

Join DonkeyMails Now | Site Details

7

PaidToClick.in

  • Ads: Low $0.0003 (7 seconds) per click but lots of ads available.
  • Payout: Minimum $2 for standard members to AlertPay and PayPal.
  • Over 100 sign up offers that pays $0.03.
  • Earn $0.05 per 1000 unique views when promoting your referral URL.
  • Referrals: Earn 20% on all referral earnings. Unlimited referrals.

Join PaidToClick.in Now | Site Details

8

BuxP

  • Ads: ~30 ads per day that pays $0.001-$0.005 per click.
  • Payout: Minimum is $8 to AlertPay and $18 if cashing out to PayPal.
  • Online since 2008 and has made over $105,000 in payments.
  • Get paid to watch videos, sign up for offers and complete surveys.
  • Referrals: Earn 50% on all earnings – up to $0.0025 for referral clicks.

Join BuxP Now | Site Details

9

Jill's Click Corner

  • Ads: Pays $0.001-$0.0001 per click. Lots of ads daily.
  • Payout: $0.10, to AlertPay, PayPal, LibertyReserve and others.
  • Signup offers worth $1500 with new ones added daily.
  • Referrals: Earn 10%, no activity needed. Unlimited referrals.
  • Monthly referral contest with a chance to win $100.

Join Jill’s Click Corner Now | Site Details

10

Logi PTC

  • Ads: Pays up to $0.01 per click. Amount of ads varies.
  • Payout: To PayPal. Minimum to cash out is $5.
  • No investing, upgrades or renting referrals. Just click ads and get paid.
  • Toolbar to get notifications when new ads are available.
  • Referrals: 10% on all earning. Unlimited number of referrals.

Join Logi PTC Now | Site Details

All click rates and referral percentages listed above are for standard (free) members. Upgraded members usually receive more money per click, more ads and a higher share on referral clicks.

Posted on 1 Comment

What is the difference between JRE, JVM and JDK?

JDK (Java Development Kit)

Java Developer Kit contains tools needed to develop the Java programs, and JRE to run the programs. The tools include compiler (javac.exe), Java application launcher (java.exe), Appletviewer, etc…

Compiler converts java code into byte code. Java application launcher opens a JRE, loads the class, and invokes its main method.

You need JDK, if at all you want to write your own programs, and to compile the m. For running java programs, JRE is sufficient.

JRE is targeted for execution of Java files

i.e. JRE = JVM + Java Packages Classes(like util, math, lang, awt,swing etc)+runtime libraries.

JDK is mainly targeted for java development. I.e. You can create a Java file (with the help of Java packages), compile a Java file and run a java file

JRE (Java Runtime Environment)

Java Runtime Environment contains JVM, class libraries, and other supporting files. It does not contain any development tools such as compiler, debugger, etc. Actually JVM runs the program, and it uses the class libraries, and other supporting files provided in JRE. If you want to run any java program, you need to have JRE installed in the system

The Java Virtual Machine provides a platform-independent way of executing code; programmers can concentrate on writing software, without having to be concerned with how or where it will run.

If u just want to run applets (ex: Online Yahoo games or puzzles), JRE needs to be installed on the machine.

JVM (Java Virtual Machine)

As we all aware when we compile a Java file, output is not an ‘exe’ but it’s a ‘.class’ file. ‘.class’ file consists of Java byte codes which are understandable by JVM. Java Virtual Machine interprets the byte code into the machine code depending upon the underlying operating system and hardware combination. It is responsible for all the things like garbage collection, array bounds checking, etc… JVM is platform dependent.

The JVM is called “virtual” because it provides a machine interface that does not depend on the underlying operating system and machine hardware architecture. This independence from hardware and operating system is a cornerstone of the write-once run-anywhere value of Java programs.

There are different JVM implementations are there. These may differ in things like performance, reliability, speed, etc. These implementations will differ in those areas where Java specification doesn’t mention how to implement the features, like how the garbage collection process works is JVM dependent, Java spec doesn’t define any specific way to do this.

 

Posted on

Install Sun/Oracle Java JDK/JRE 7 on Linux Fedora, CentOS/RHEL

This is a guide about how to Install Sun/Oracle Java JDK and JRE 7 update 2 (7u2) on Fedora 16, Fedora 15, Fedora 14, Fedora 13, Fedora 12, CentOS 6.1/6/5.7, Red Hat (RHEL) 6.1/6/5.7.

If you’re looking instruction for Sun/Oracle Java JDK/JRE version 6 installation on Fedora 16/15, CentOS/Red Hat (RHEL) 6.1/5.7, please check this guide.

What’s new in Sun/Oracle Java 7

  • VM
    • Compressed 64-bit object pointers
    • Garbage-First GC (G1)
    • JSR 292: VM support for non-Java languages (InvokeDynamic)
  • Lang
    • JSR 294: Language and VM support for modular programming
    • JSR 308: Annotations on Java types
    • JSR TBD: Small language enhancements (Project Coin)
    • JSR TBD: Project Lambda
  • Core
    • Modularization (Project Jigsaw)
    • Upgrade class-loader architecture
    • Method to close a URLClassLoader
    • Unicode 5.1
    • Concurrency and collections updates (jsr166y)
    • JSR 203: More new I/O APIs for the Java platform (NIO.2)
    • SCTP (Stream Control Transmission Protocol)
    • SDP (Sockets Direct Protocol)
    • Elliptic-curve cryptography (ECC)
  • Client
    • XRender pipeline for Java 2D
    • Forward-port 6u10 deployment features
    • Create new platform APIs for 6u10 graphics features
    • Nimbus look-and-feel for Swing
    • Swing JLayer component
  • Web
    • Update the XML stack

Read full info from here.

If you don’t know what is the difference between JRE, JVM and JDK, read here.

Install Sun/Oracle Java JDK/JRE 7u2 on Fedora 16/15/14/13/12, CentOS 6.1/6/5.7, Red Hat (RHEL) 6.1/6/5.7

1. Download Sun/Oracle Java JDK/JRE 7u2 32-bit/64-bit RPM packages

Download Sun/Oracle Java 7u2 from here http://www.oracle.com/technetwork/java/javase/downloads/index.html. Select rpm package (jdk-7u2-linux-i586.rpm, jdk-7u2-linux-x64.rpm, jre-7u2-linux-i586.rpm or jre-7u2-linux-x64.rpm).

2. Change to root user.

sudo -i
## OR ##
su -

3. Install Java JDK or JRE package

## JDK 32-bit ##
rpm -Uvh /path/to/binary/jdk-7u2-linux-i586.rpm

## JDK 64-bit ##
rpm -Uvh /path/to/binary/jdk-7u2-linux-x64.rpm

## JRE 32-bit ##
rpm -Uvh /path/to/binary/jre-7u2-linux-i586.rpm

## JRE 64-bit ##
rpm -Uvh /path/to/binary/jre-7u2-linux-x64.rpm

4a. Install Sun/Oracle JDK java, javaws, libjavaplugin.so (for Firefox/Mozilla) and javac with alternatives –install command

Use Java JDK latest version (/usr/java/latest)

## java ##
alternatives --install /usr/bin/java java /usr/java/latest/jre/bin/java 20000
## javaws ##
alternatives --install /usr/bin/javaws javaws /usr/java/latest/jre/bin/javaws 20000

## Java Browser (Mozilla) Plugin 32-bit ##
alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so
/usr/java/latest/jre/lib/i386/libnpjp2.so 20000

## Java Browser (Mozilla) Plugin 64-bit ##
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64
/usr/java/latest/jre/lib/amd64/libnpjp2.so 20000

## Install javac only if you installed JDK (Java Development Kit) package ##
alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 20000
alternatives --install /usr/bin/jar jar /usr/java/latest/bin/jar 20000

Use Java JDK absolute version (/usr/java/jdk1.7.0_02)

## java ##
alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_02/jre/bin/java 20000
## javaws ##
alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.7.0_02/jre/bin/javaws 20000

## Java Browser (Mozilla) Plugin 32-bit ##
alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so
/usr/java/jdk1.7.0_02/jre/lib/i386/libnpjp2.so 20000

## Java Browser (Mozilla) Plugin 64-bit ##
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64
/usr/java/jdk1.7.0_02/jre/lib/amd64/libnpjp2.so 20000

## Install javac only if you installed JDK (Java Development Kit) package ##
alternatives --install /usr/bin/javac javac /usr/java/jdk1.7.0_02/bin/javac 20000
alternatives --install /usr/bin/jar jar /usr/java/jdk1.7.0_02/bin/jar 20000

4b. Install Sun/Oracle JRE java, javaws and libjavaplugin.so
(for Firefox/Mozilla) with alternatives –install command

Use Java JRE latest version (/usr/java/latest)

## java ##
alternatives --install /usr/bin/java java /usr/java/latest/bin/java 20000

## javaws ##
alternatives --install /usr/bin/javaws javaws /usr/java/latest/bin/javaws 20000

## Java Browser (Mozilla) Plugin 32-bit ##
alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so
/usr/java/latest/lib/i386/libnpjp2.so 20000

## Java Browser (Mozilla) Plugin 64-bit ##
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64
/usr/java/latest/lib/amd64/libnpjp2.so 20000

Use Java JRE absolute version (/usr/java/jre1.7.0_02)

## java ##
alternatives --install /usr/bin/java java /usr/java/jre1.7.0_02/bin/java 20000

## javaws (32-bit only) ##
alternatives --install /usr/bin/javaws javaws /usr/java/jre1.7.0_02/bin/javaws 20000

## Java Browser (Mozilla) Plugin 32-bit ##
alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so
/usr/java/jre1.7.0_02/lib/i386/libnpjp2.so 20000

## Java Browser (Mozilla) Plugin 64-bit ##
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64
/usr/java/jre1.7.0_02/lib/amd64/libnpjp2.so 20000

5. Check current java, javac, javaws and libjavaplugin.so versions

java -version
java version "1.7.0_02"
Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)

javaws
Java(TM) Web Start 1.7.0_02
[...]

javac -version
javac 1.7.0_02

Note: Check libjavaplugin.so with restarting Mozilla Firefox and writing about:plugins on address bar.

6. Swap between OpenJDK and Sun/Oracle Java JDK/JRE 6 and 7 versions

java

alternatives --config java

There are 5 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*  1           /usr/java/jdk1.6.0_24/jre/bin/java
   2           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
 + 3           /usr/java/jdk1.6.0_26/jre/bin/java
   4           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
   5           /usr/java/jdk1.7.0_02/jre/bin/java

Enter to keep the current selection[+], or type selection number: 5

Note: java with [+] is currently on use

javaws

alternatives --config javaws

There are 3 programs which provide 'javaws'.

  Selection    Command
-----------------------------------------------
*  1           /usr/java/jdk1.6.0_24/jre/bin/javaws
 + 2           /usr/java/jdk1.6.0_26/jre/bin/javaws
   3           /usr/java/jdk1.7.0_02/jre/bin/javaws

Enter to keep the current selection[+], or type selection number: 3

Note: java with [+] is currently on use

libjavaplugin.so (32-bit)

alternatives --config libjavaplugin.so

There are 3 programs which provide 'libjavaplugin.so'.

  Selection    Command
-----------------------------------------------
*  1           /usr/java/jdk1.6.0_24/jre/lib/i386/libnpjp2.so
 + 2           /usr/java/jdk1.6.0_26/jre/lib/i386/libnpjp2.so
   3           /usr/java/jdk1.7.0_02/jre/lib/i386/libnpjp2.so

Enter to keep the current selection[+], or type selection number: 3

libjavaplugin.so.x86_64 (64-bit)

alternatives --config libjavaplugin.so.x86_64

There are 3 programs which provide 'libjavaplugin.so.x86_64'.

  Selection    Command
-----------------------------------------------
*  1           /usr/java/jdk1.6.0_24/jre/lib/amd64/libnpjp2.so
 + 2           /usr/java/jdk1.6.0_26/jre/lib/amd64/libnpjp2.so
   3           /usr/java/jdk1.7.0_02/jre/lib/amd64/libnpjp2.so

Enter to keep the current selection[+], or type selection number: 3

javac

alternatives --config javac

There are 3 programs which provide 'javac'.

  Selection    Command
-----------------------------------------------
*  1           /usr/java/jdk1.6.0_24/bin/javac
 + 2           /usr/java/jdk1.6.0_26/bin/javac
   3           /usr/java/jdk1.7.0_02/bin/javac

Enter to keep the current selection[+], or type selection number: 3

Note: java with [+] is currently on use

Post-Installation Setup

Add JAVA_HOME environment variable to /etc/profile file or $HOME/.bash_profile file

Java JDK and JRE latest version (/usr/java/latest)

## export JAVA_HOME JDK/JRE ##
export JAVA_HOME="/usr/java/latest"

Java JDK and JRE absolute version (/usr/java/jdk1.7.0_02)

## export JAVA_HOME JDK ##
export JAVA_HOME="/usr/java/jdk1.7.0_02"

## export JAVA_HOME JRE ##
export JAVA_HOME="/usr/java/jre1.7.0_02"
Posted on

PHP MySQL Update

The UPDATE statement is used to modify data in a table.


Update Data In a Database

The UPDATE statement is used to update existing records in a table.

Syntax

UPDATE table_name
SET column1=value, column2=value2,…
WHERE some_column=some_value

Note:Notice the WHERE clause in the UPDATE syntax. The WHERE clause specifies which record or records that should be updated. If you omit the WHERE clause, all records will be updated!

To learn more about SQL, please visit our SQL tutorial.

To get PHP to execute the statement above we must use the mysql_query() function. This function is used to send a query or command to a MySQL connection.

Example

Earlier in the tutorial we created a table named “Persons”. Here is how it looks:

FirstName LastName Age
Peter Griffin 35
Glenn Quagmire 33

The following example updates some data in the “Persons” table:

<?php
$con = mysql_connect(“localhost”,”peter”,”abc123″);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}

mysql_select_db(“my_db”, $con);

mysql_query(“UPDATE Persons SET Age = ’36’
WHERE FirstName = ‘Peter’ AND LastName = ‘Griffin'”);

mysql_close($con);
?>

After the update, the “Persons” table will look like this:

FirstName LastName Age
Peter Griffin 36
Glenn Quagmire 33
Posted on

PHP MySQL The Where Clause

The WHERE clause is used to filter records.


The WHERE clause

The WHERE clause is used to extract only those records that fulfill a specified criterion.

Syntax

SELECT column_name(s)
FROM table_name
WHERE column_name operator value

To learn more about SQL, please visit our SQL tutorial.

To get PHP to execute the statement above we must use the mysql_query() function. This function is used to send a query or command to a MySQL connection.

Example

The following example selects all rows from the “Persons” table where “FirstName=’Peter’:

<?php
$con = mysql_connect(“localhost”,”peter”,”abc123″);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}mysql_select_db(“my_db”, $con);

$result = mysql_query(“SELECT * FROM Persons
WHERE FirstName=’Peter'”);

while($row = mysql_fetch_array($result))
{
echo $row[‘FirstName’] . ” ” . $row[‘LastName’];
echo “<br />”;
}
?>

The output of the code above will be:

Peter Griffin
________________________________________________________

PHP MySQL Order By Keyword

The ORDER BY keyword is used to sort the data in a recordset.


The ORDER BY Keyword

The ORDER BY keyword is used to sort the data in a recordset.

The ORDER BY keyword sort the records in ascending order by default.

If you want to sort the records in a descending order, you can use the DESC keyword.

Syntax

SELECT column_name(s)
FROM table_name
ORDER BY column_name(s) ASC|DESC

To learn more about SQL, please visit our SQL tutorial.

Example

The following example selects all the data stored in the “Persons” table, and sorts the result by the “Age” column:

<?php
$con = mysql_connect(“localhost”,”peter”,”abc123″);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}

mysql_select_db(“my_db”, $con);

$result = mysql_query(“SELECT * FROM Persons ORDER BY age”);

while($row = mysql_fetch_array($result))
{
echo $row[‘FirstName’];
echo ” ” . $row[‘LastName’];
echo ” ” . $row[‘Age’];
echo “<br />”;
}

mysql_close($con);
?>

The output of the code above will be:

Glenn Quagmire 33
Peter Griffin 35

 


Order by Two Columns

It is also possible to order by more than one column. When ordering by more than one column, the second column is only used if the values in the first column are equal:

SELECT column_name(s)
FROM table_name
ORDER BY column1, column2
Posted on

PHP MySQL Select

The SELECT statement is used to select data from a database.


Select Data From a Database Table

The SELECT statement is used to select data from a database.

Syntax

SELECT column_name(s)
FROM table_name

To learn more about SQL, please visit our SQL tutorial.

To get PHP to execute the statement above we must use the mysql_query() function. This function is used to send a query or command to a MySQL connection.

Example

The following example selects all the data stored in the “Persons” table (The * character selects all the data in the table):

<?php
$con = mysql_connect(“localhost”,”peter”,”abc123″);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}

mysql_select_db(“my_db”, $con);

$result = mysql_query(“SELECT * FROM Persons”);

while($row = mysql_fetch_array($result))
{
echo $row[‘FirstName’] . ” ” . $row[‘LastName’];
echo “<br />”;
}

mysql_close($con);
?>

The example above stores the data returned by the mysql_query() function in the $result variable.

Next, we use the mysql_fetch_array() function to return the first row from the recordset as an array. Each call to mysql_fetch_array() returns the next row in the recordset. The while loop loops through all the records in the recordset. To print the value of each row, we use the PHP $row variable ($row[‘FirstName’] and $row[‘LastName’]).

The output of the code above will be:

Peter Griffin
Glenn Quagmire

 


Display the Result in an HTML Table

The following example selects the same data as the example above, but will display the data in an HTML table:

<?php
$con = mysql_connect(“localhost”,”peter”,”abc123″);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}

mysql_select_db(“my_db”, $con);

$result = mysql_query(“SELECT * FROM Persons”);

echo <table border=’1′>
<
tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>”;

while($row = mysql_fetch_array($result))
{
echo “<tr>”;
echo “<td>” . $row[‘FirstName’] . “</td>”;
echo “<td>” . $row[‘LastName’] . “</td>”;
echo “</tr>”;
}
echo “</table>”;

mysql_close($con);
?>

The output of the code above will be:

Firstname Lastname
Glenn Quagmire
Peter Griffin
Posted on

PHP MySQL Insert Into a Table

The INSERT INTO statement is used to insert new records in a table.


Insert Data Into a Database Table

The INSERT INTO statement is used to add new records to a database table.

Syntax

It is possible to write the INSERT INTO statement in two forms.

The first form doesn’t specify the column names where the data will be inserted, only their values:

INSERT INTO table_name
VALUES (value1, value2, value3,…)

The second form specifies both the column names and the values to be inserted:

INSERT INTO table_name (column1, column2, column3,…)
VALUES (value1, value2, value3,…)

To learn more about SQL, please visit our SQL tutorial.

To get PHP to execute the statements above we must use the mysql_query() function. This function is used to send a query or command to a MySQL connection.

Example

In the previous chapter we created a table named “Persons”, with three columns; “Firstname”, “Lastname” and “Age”. We will use the same table in this example. The following example adds two new records to the “Persons” table:

<?php
$con = mysql_connect(“localhost”,”peter”,”abc123″);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}

mysql_select_db(“my_db”, $con);

mysql_query(“INSERT INTO Persons (FirstName, LastName, Age)
VALUES (‘Peter’, ‘Griffin’, ’35’)”);

mysql_query(“INSERT INTO Persons (FirstName, LastName, Age)
VALUES (‘Glenn’, ‘Quagmire’, ’33’)”);

mysql_close($con);
?>

 


Insert Data From a Form Into a Database

Now we will create an HTML form that can be used to add new records to the “Persons” table.

Here is the HTML form:

<html>
<body>

<form action=”insert.php” method=”post”>
Firstname: <input type=”text” name=”firstname” />
Lastname: <input type=”text” name=”lastname” />
Age: <input type=”text” name=”age” />
<input type=”submit” />
</form>

</body>
</html>

When a user clicks the submit button in the HTML form in the example above, the form data is sent to “insert.php”.

The “insert.php” file connects to a database, and retrieves the values from the form with the PHP $_POST variables.

Then, the mysql_query() function executes the INSERT INTO statement, and a new record will be added to the “Persons” table.

Here is the “insert.php” page:

<?php
$con = mysql_connect(“localhost”,”peter”,”abc123″);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}

mysql_select_db(“my_db”, $con);

$sql=”INSERT INTO Persons (FirstName, LastName, Age)
VALUES
(‘$_POST[firstname]’,’$_POST[lastname]’,’$_POST[age]’)”;

if (!mysql_query($sql,$con))
{
die(‘Error: ‘ . mysql_error());
}
echo “1 record added”;

mysql_close($con)
?>

Posted on

PHP MySQL Create Database and Tables

A database holds one or multiple tables.


Create a Database

The CREATE DATABASE statement is used to create a database in MySQL.

Syntax

CREATE DATABASE database_name

To learn more about SQL, please visit our SQL tutorial.

To get PHP to execute the statement above we must use the mysql_query() function. This function is used to send a query or command to a MySQL connection.

Example

The following example creates a database called “my_db”:

<?php
$con = mysql_connect(“localhost”,”peter”,”abc123″);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}

if (mysql_query(“CREATE DATABASE my_db”,$con))
{
echo “Database created”;
}
else
{
echo “Error creating database: ” . mysql_error();
}

mysql_close($con);
?>

 


Create a Table

The CREATE TABLE statement is used to create a table in MySQL.

Syntax

CREATE TABLE table_name
(
column_name1 data_type,
column_name2 data_type,
column_name3 data_type,
….

)

To learn more about SQL, please visit our SQL tutorial.

We must add the CREATE TABLE statement to the mysql_query() function to execute the command.

Example

The following example creates a table named “Persons”, with three columns. The column names will be “FirstName”, “LastName” and “Age”:

<?php
$con = mysql_connect(“localhost”,”peter”,”abc123″);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}

// Create database
if (mysql_query(“CREATE DATABASE my_db”,$con))
{
echo “Database created”;
}
else
{
echo “Error creating database: ” . mysql_error();
}

// Create table
mysql_select_db(“my_db”, $con);
$sql = “CREATE TABLE Persons
(
FirstName varchar(15),
LastName varchar(15),
Age int
)”;

// Execute query
mysql_query($sql,$con);

mysql_close($con);
?>

Important: A database must be selected before a table can be created. The database is selected with the mysql_select_db() function.

Note: When you create a database field of type varchar, you must specify the maximum length of the field, e.g. varchar(15).

The data type specifies what type of data the column can hold. For a complete reference of all the data types available in MySQL, go to our complete Data Types reference.


Primary Keys and Auto Increment Fields

Each table should have a primary key field.

A primary key is used to uniquely identify the rows in a table. Each primary key value must be unique within the table. Furthermore, the primary key field cannot be null because the database engine requires a value to locate the record.

The following example sets the personID field as the primary key field. The primary key field is often an ID number, and is often used with the AUTO_INCREMENT setting. AUTO_INCREMENT automatically increases the value of the field by 1 each time a new record is added. To ensure that the primary key field cannot be null, we must add the NOT NULL setting to the field.

Example

$sql = “CREATE TABLE Persons
(
personID int NOT NULL AUTO_INCREMENT,
PRIMARY KEY(personID),
FirstName varchar(15),
LastName varchar(15),
Age int
)”;

mysql_query($sql,$con);

Posted on

Connect to a MySQL Database with PHP

The free MySQL database is very often used with PHP.


Create a Connection to a MySQL Database

Before you can access data in a database, you must create a connection to the database.

In PHP, this is done with the mysql_connect() function.

Syntax

mysql_connect(servername,username,password);

 

Parameter Description
servername Optional. Specifies the server to connect to. Default value is “localhost:3306”
username Optional. Specifies the username to log in with. Default value is the name of the user that owns the server process
password Optional. Specifies the password to log in with. Default is “”

Note: There are more available parameters, but the ones listed above are the most important. Visit our full PHP MySQL Reference for more details.

Example

In the following example we store the connection in a variable ($con) for later use in the script. The “die” part will be executed if the connection fails:

<?php
$con = mysql_connect(“localhost”,”peter”,”abc123″);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}

// some code
?>

 


Closing a Connection

The connection will be closed automatically when the script ends. To close the connection before, use the mysql_close() function:

<?php
$con = mysql_connect(“localhost”,”peter”,”abc123″);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}

// some code

mysql_close($con);
?>

Posted on

Everything about Gobelins Tapestry

The Gobelin is a “painting by needle stitch”

It’s related to tapestry, but instead of being woven, it is sewn on canvas with a fine needle, point by point, in a process that may take anywhere from 3 months to 1 year, depending on size of the piece, complexity of the design, size of the needle point, number of threads and their thickness and the total number of colors.
While the terms “needlepoint”, “tapestry”, “embroidery” and “needlework” are all related, the correct English description for Gobelin is “needlepoint”: this refers to a particular set of stitching techniques worked upon stiff openwork canvas. “Needlepoint” is not synonymous with all types of embroidery. Needlepoint is often referred to as “tapestry” but differs from true tapestry, which is woven on a loom, rather than stitched on canvas. When worked on fine weave canvas in tent stitch, it is also known as “Petit point”, from French.

When referring to handcrafted textile arts which a speaker is unable to identify, the appropriate generalized term is “needlework”.

The Gobelin originated in the manufactures by the same name, in France and were a form of intricate tapestry.

The modern Gobelins are a form of craft work by needle stitching. It is different from the well-known “cross stitch” like going from the kindergarten of needle work, to university. First of all the Gobelin requires a more complex technique, large number of colors (anywhere from maybe 20 to 90) and intricate patterns, a finer point called “petit point”, which results in a type of work that from a distance is hardly distinguishable from an oil painting. And maybe that is why a great number of goblins are replicas of well-known painting masterpieces.
nowadays apart from the Gobelin classics such as reproductions from Fragonard, Monet or van Gogh, you can have a family photo, or your favorite holiday shot digitized and printed on canvas ready for you to sew into a beautiful Gobelin piece.

The classic Gobelins will give a touch of class to your home, or you may turn to original contemporary designs or personal photography if you prefer a modern look for your home.

Whatever you may choose, the Gobelins are a durable work of art that will last for generations, while they carry with them the passion for harmony and beauty of the person who has sewn them. This is why I call them “an art for eternity”.

Gobelins History

Modern-day gobelins emerged along with a textile factory in Paris, named after a family of French dyers. The enterprise began in the mid-15th century, when Jean Gobelin and Philibert Gobelin set up a dye works on the outskirts of Paris. The family business flourished, and in the early 17th century King Henry IV of France turned the works into a tapestry factory under Flemish weavers. The luxurious products of the Gobelins factory became so famous that the establishment was taken over in 1662 by King Louis XIV’s finance minister Jean Baptiste Colbert to form part of the Royal Manufactory of Furniture. Colbert placed the French painter Charles Lebrun in charge, and he commissioned designs by the best artists of the day, setting high standards of execution and encouraging the training of new artisans. The result was an outpouring of magnificent hangings, upholstery, and furniture in a richly ornate, baroque style.

The Gobelins factory closed from 1694 to 1699, owing to the Crown’s financial difficulties. It reopened solely to make tapestries and has continued, with a brief interruption during the French Revolution, ever since. With the years, styles changed to rococo, neoclassical, and modern. In 1825 the factory absorbed the Savonnerie rug works, founded in 1627. It is now officially called the Manufacture Nationale de Gobelins.

Browse our Gobelin Products