Perfect Guide

Posts tagged ‘PHP’

Compatibility of PHP

PHP can be used on all major operating systems (Windows, UNIX, Mac And probably RISC) also with many others because this is cross platform open source programming language.

PHP is also many web servers like APACHE and many others like WAMP. People works as either module or CGI processor.

Above paragraph told me that using PHP, I have the freedom of selecting operating system and a web server. I have also the choice of using programming method. I can use procedural programming, Object oriented programming or mixture of both.[More..]

Easier Way to connect your PHP page with your database server??

Easier Way to connect your PHP page with your database server??

I am going to give you a simple prescription to connect your PHP page with your database server.

Just follow  steps and make it easier for you:)

SYNTAX:

<?php

$db = mysql_connect('YOUR_DB_ADDRESS','YOUR_DB_USER','YOUR_DB_PASS') or die("Database error");
mysql_select_db('YOUR_DB', $db); 
?>

  • Create a new php file with “.php” extension
  • Define variables for “server”,”user_name”,”password”,”database”($servername,$username,$password,$database).

$servername     =             “localhost”;

$username         =             “root”;

$password          =             “vertrigo”; //as my password is VERTRIGO

$database           =             “dbform”;

  • Define a variable of link($link) using built-in function in php

$link       =             mysql_connect( $servername, $username, $password);

  • The next step is to select database, the following code represent you to how to select database

  Mysql_select_db($database,$link);

Complete Code of Connection


<?php 		//connection to mysql 		
$servername		=	"localhost"; // 127.0.0.1 
$uname			=	"root"; 	
$password		=	"vertrigo";
$database		=	"dbform"; 	
$link	                =mysql_connect($servername,$uname,$password); 						mysql_select_db($database,$link); 
?>
  • Now simply save this file with name connection.php
  • You can include this file with any of your php page for connection, there is no need to create the connection every time! Simply include it and enjoy

HOW TO INCLUDE?

<?php

Include”connection.php”

?>

 

 

What is PHP and why PHP?

WHAT and WHY?

Many of my friends have confusions that why to use PHP? Why not another one? Many questions also bump their head that what is PHP? What it actually do?

I have some points which going to make clear all these questions. These will also make clear all the fundamentals and gossips about PHP. So let’s go:

  • PHP: “hypertext preprocessor” is commonly used open source scripting language.
  • PHP is widely used general purpose scripting language that was originally designed for web development to produce dynamic web pages.
  • A scripting language widely used to write web applications.
  • A general purpose server side scripting language.
  • It can be embedded into HTML to create a wide variety of mini –applications.
  • It can also be used for large type of complex applications.
  • PHP is used for populating dynamic web pages.
  • Embedded into HTML; HTML as output and PHP as input.
  • It is part of LAMP (Linux APACHE MySQL PHP) environment.
  • PHP can be used for same type of applications like ASP and .NET, but its free and open source while the other ones are not.
  • Its advantage over JavaScript is that it runs on the web-server rather than viewer’s PC or Mac.
  • Generally used by LINUX, UNIX and Solaris Platform.7
  • PHP is cross platform
  • PHP supports many databases (MySQL, Oracle, etc)
  • PHP has extension of files “.php”, “.php3” and “.phtml”.

Client Side & Server Side Scripting Languages For Web!

Client Side:

It generally refers to the class of computer programs on the web that are executed client side by the user.

This type of programing is an important concept as the part of Dynamic HTML (DHTML) enabling web pages

to be scripted. Client side scripting languages are Javascript and VBscript.

Server Side:

It is a web server technology in which a user’s request is verified by running a script directly on the web server to generate Dynamic pages.

It is usually used to provide interactive web site that provide interface to database or the other database.

From Security Point of view, server side scripts are never visible to the browser as these scripts are executed on the server and emit HTML corresponding to user’s input to the Page.

 Todays examles for server side languages are PHP, ASP and .NET

%d bloggers like this: