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
Stored Procedure returns data from multiple tables. How to access it in your ASP.Net code?
Explain iaas, paas and saas?
Explain transaction server distributed transaction?
Explain what is it unwise to create wide clustered index keys?
Explain powershell included in sql server 2008?
What are extended events in sql server?
How to create a view on an existing table in ms sql server?
According to you what goes into making the best database administrator? : sql server database administration
Explain error and transaction handling in sql server?
How to delete a database in ms sql server?
How can you insert values in multiple rows using one Insert statement?
mention different types of relationships in the dbms?
What is statement level trigger?
What is precedence constraint?
Can two tables share a primary key?