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
What is difference between views and tables?
How to loop through result set objects using mssql_fetch_array()?
In one interview...interviewer ask me question pleas tell me sql server architecture.. can any body tell me the sql server architecture with digram
How optimize sql query with multiple joins in sql server?
What is the difference between for trigger and after trigger?
As a general practice, it is recommended to have dbo be the owner of all database objects however, in your database you find number of tables owned by a user other than dbo, how could you fix this?
When should you use an instead of trigger?
How to make a column nullable?
What is table join?
What do you understand by a stored procedure?
How does stuff differ from the replace function?
What is the library index called?
how would you improve etl (extract, transform, load) throughput?
Explain tables in SQL Azure?
how to control the amount of free space in your index pages? : Sql server database administration