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
How sql server executes a statement with nested subqueries?
What is change data capture (cdc) in sql server 2008?
Explain DBCC?
What is indexed view?
What is normalization and what are the advantages of it?
Which table keeps the locking information?
How do I start and stop sql server?
Do you know what is a linked server in sql server?
What are group functions in query statements in ms sql server?
What are the differences between clustered and non-clustered index?
What is difference between joins and subqueries?
How to resolve the orphan use problem? : sql server security
what is the difference between delete table and truncate table commands? : Sql server database administration
How you can get a list of all the table constraints in a database?
How display code or Text of Stored Procedure using Sql query in Sql Server ?