PHP/MySQL Tutorial – PHP MySQL Connection

By | March 13, 2013

PHP/My SQL Tutorial- PHP/My SQL connection

Querying the Database

Step 3: the two methods by which one can query the database is – the first one is to enter the command in PHP and second one is to define the commands as variable. We provide google web hosting India

Here we will display you the first way, as the command will appear like this:

mysql_query ($query);

Modify the variable, so that the command can be repeated again and again in the source code.

For creating the My SQL table in PHP, you can see the complete code mentioned here:

$user= “username”;
$password= “password”;
$database= “database”;
mysql_connect (localhost,$user,$password);
@mysql_select_db($database) or die ( “Unable to select database”);
$query= “CREATE TABLE tablename(id int(6) NOT NULL auto_increment,first varchar(15) NOT NULL, last varchar(15) NOT NULL,field1-name varchar(20) NOT NULL,field2-name varchar(20) NOT NULL,field3-name varchar(20) NOT NULL,field4-name varchar(30) NOT NULL,field5-name varchar(30) NOT NULL,PRIMARY KEY (id),UNIQUE id (id),KEY id_2 (id))”;

In the first three lines, fill your complete information My SQL Username and password in the space provided:

The next query include filling the table like-

$query = “INSERT INTO tablename VALUES 

Here, more values can be entered than the number of fields created in the first query. We provide reliable web hosting india

Leave a Reply