MySQL PHP Connection

July 28th, 2010 admin No comments

Before you can do anything with MySQL in PHP you must first establish a connection to your web host’s MySQL database. This is done with the MySQL connect function.

Syantax

mysql_connect(servername,username,password);

Example

mysql_connect(“localhost”,”guest”,”abc123″);

Example with PHP

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

<html>
<head>
<title>Connecting MySQL Server</title>
</head>
<body>
<?php
$dbhost = ‘localhost’;
$dbuser = ‘guest’;
$dbpass = ‘abc123′;
$connection = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $connection)
{
die(‘Could not connect: ‘ . mysql_error());
}
echo ‘Connected successfully’;
mysql_close($connection);
?>
</body>
</html>

You can disconnect from MySQL database anytime using another PHP function mysql_close().

Categories: MySql Tags:

MySQL Tutorial with PHP Examples

July 28th, 2010 admin No comments

MySQL is the open-source database system.

Database: A database is a collection of tables, with related data.

Table: A table is a collections of related data entries and it consists of columns and rows.

Databases are useful when storing information categorically. A college may have a database with the following tables: “Employees”, “Students” and “Departments”.

MySQL PHP Syntax

MySQL works very well in combination of various programming languages like PERL,JAVA and PHP. Out of these languages, PHP is the most popular one because of its web application development capabilities.

This tutorial focuses heavily on using MySQL in a PHP environment. PHP provides various functions to access MySQL database and to manipulate data records inside MySQL database.

The PHP functions for use with MySQL have the following general format:

mysql_function(arg 01,arg 02,…);

Categories: MySql Tags:

WordPress 3.0 Installation Tutorial

July 23rd, 2010 admin No comments

How to install latest version WordPress 3.0?

Here i am giving instructions about how to install wordpress in localhost. We can apply the same steps to live websites too.

After download the wordpress , we should unzip the file.It contains 3 folders(wp-admin , wp-content, wp-includes) and files.

wp-admin is for admin

wp-includes contains supporting files and function

wp-content folder contains plugins(place to add plugins to the website) and themes(place to add/modify the website frontend)folder.

And before starting the installation, we should create a database for this website.

For example, i have created a database name : phpneedswp

Then we should copy the wordpress folder into www folder.

First step, type the following address in address bar.

http://localhost/wordpress/

Now this page will appears on the screen.

Click on “Click a Configuration File” Button.

Now your address bar shows this location “http://localhost/wordpress/wp-admin/setup-config.php” and your monitor displays the following screen.

Now we should click on “Let’s-Go” Button.

Now the address bar displays this address “http://localhost/wordpress/wp-admin/setup-config.php?step=1″ and it shows the following screen.

This is important step, we should enter the values in the follwing fields.

Database Name : The name of the database you want to run WP in.(Example: phpneedswp)

User Name : Your MySQL username (Example: root)

Password : Your MySQL password(Generally empty in localhost for root)

Database Host : You should be able to get this info from your web host, if localhost does not work.(Example: localhost)

Table Prefix: If you want to run multiple WordPress installations in a single database, change this.(Now simply leave this as it is)

After Entering the details , Click “Submit” button. It shows the following screen.

Next Click “Run the Install” button.

Now it shows the following screen.

Next Step,

Now, We should Enter the Site Name, User Name(Default is admin, if u want to change u can change to ur need), Password(Enter the same password twice) and Email Id.Leave the check box as it is.

After enter all the details, Click ” Install WordPress” button. Now the monitor shows the following screen.

Yes. Your WordPress installation is now Completed.

To access your wordpress frontpage, type this in your address bar.

http://localhost/wordpress

it shows your fresh wordpress website.

To add/edit/delete(login) your wordpress post, we should access this location.

http://localhost/wordpress/wp-admin/

What is WordPress?

July 23rd, 2010 admin No comments

WordPress is Open Source web software you can use to create a attractive website or blog. We like to say that WordPress is both free and priceless at the same time.

We can download the WordPress software from this link.

Download

Please download the latest/stable version of wordpress. And also we can get the wordpress archive from here.

http://wordpress.org/download/release-archive/

We can change the wordpress look and feel using themes and we can add the functionality to website using plugins.