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

explain what is raid and what are different types of raid configurations? : Sql server database administration

626


What are the elements of dbms?

626


What is a virtual table in sql?

623


How to check table values in sql server?

607


what is blocking? : Sql server database administration

593






How to add code to the existing article (using improve article)?

682


What are the built in functions in sql server?

571


What is a data source file?

576


Explain how to integrate the ssrs reports in application?

592


How do you make a trace?

665


What is catalog views?

699


How do I get Report Builder to generate a parameter that can be set by users viewing the report?

116


explain different types of cursors? : Sql server database administration

652


How to perform key word search in tables?

604


Explain syntax for viewing trigger?

617