/******************MYSQL with PHP*********************************/
/*****This program shows how to create a table in a database using php******/
 die("Not Connected" . mysql_error());
 mysql_query("CREATE TABLE priya(Rollno INT NOT NULL AUTO_INCREMENT,Student_Name varchar(30), Marks INT,PRIMARY KEY (Rollno))");
 mysql_query("INSERT INTO priya(Rollno,Student_Name,Marks) VALUES(106160,'Priyanka Kapoor', 95)");
 $table=mysql_query("SELECT * FROM priya");
 echo $table;
 echo "Tables Created!!!";

die() function:-

The die() function prints a message and exits the current script. This function is an alias of the exit() function.

Syntax:- die(message)

mysql.error() function:-

The mysql_error() function returns the error description of the last MySQL operation.

This function returns an empty string (” “) if no error occurs.

Syntax:- mysql_error(connection)

mysql_query() function:-

The mysql_query() function executes a query on a MySQL database.

Syntax:- mysql_query(query,connection)

query: Required. Specifies the SQL query to send (should not end with a semicolon)

connection: Optional. Specifies the MySQL connection. If not specified, the last connection opened by mysql_connect() or mysql_pconnect() is used.


The mysql_connect() function opens a non-persistent MySQL connection. This function returns the connection on success, or FALSE and an error on failure. You can hide the error output by adding an ‘@’ in front of the function name.

Syntax:- mysql_connect(server,username,password)

mysql_select_db() function:-

The mysql_select_db() function sets (selects) the active MySQL database.

Syntax:- mysql_select_db(database,connection)

About Priyanka Kapoor

Simple, Hardworking & friendly.....
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s