how we can use a database with php.

Answer Posted / shrikant

mysql> CREATE DATABASE first_test;
Query OK, 1 row affected (0.31 sec)
mysql> USE first_test;
Database changed
mysql> CREATE TABLE people (
id int UNIQUE NOT NULL,
first_name varchar(40),
surname varchar(50),
PRIMARY KEY(id)
);
Query OK, 0 rows affected (0.24 sec)
mysql> INSERT INTO people VALUES(1,'Ann','Brache');
Query OK, 1 row affected (0.09 sec)
mysql> INSERT INTO people VALUES(2,'Narcizo','Levy');
Query OK, 1 row affected (0.02 sec)
mysql> INSERT INTO people VALUES(3,'Tony','Crocker');
Query OK, 1 row affected (0.00 sec)

Your table should now look as follows:

mysql> SELECT * FROM people;
+----+------------+---------+
| id | first_name | surname |
+----+------------+---------+
| 1 | Ann | Brache |
| 2 | Narcizo | Levy |
| 3 | Tony | Crocker |
+----+------------+---------+
and for connecting

<?php
$username = "username";
$password = "password";
$hostname = "localhost";
$dbh = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the log shipping?

753


What is the parse query button used for?

791


How to find Duplicate Records In table?

759


What is the rdl file?

98


Explain security with sql azure?

171






How do I find the default sql server instance?

695


What is BCP? When does it used in sql server 2012?

755


What are subqueries in sql server?

792


Explain error and transaction handling in sql server?

681


Write a SQL query in order to merge two different columns into single column?

810


How we create SQL Server 2005 Reporting Services ? Give me Sample

1740


What is difference between views and tables?

639


What is trigger and different types of Triggers?

810


What is function of CUBE ?

760


What is provisioning, billing and metering, and connection routing concepts in the service layer?

109