LAMP_TRAINING_SESSION_8

909 views

Published on

Presentaions of LAMP Training Conducted by T.Umapathi Anand and R.Kasturi from Southern Telecom Region, BSNL at RTTC Trivandrum.

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
909
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
20
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

LAMP_TRAINING_SESSION_8

  1. 1. Connecting to MySQL <?php $con = mysql_connect(‘localhost’,’lampusr’,’lamppwd’); If($con) { echo “Connected”; }else{ echo “Could not connect to MySQL”; exit(); } ?>
  2. 2. Closing MySQL <?php $con = mysql_connect(‘localhost’,’lampusr’,’lamppwd’); If($con) { echo “Connected”; // do some work with mysql mysql_close($con); }else{ echo “Could not connect to MySQL”; exit(); } ?>
  3. 3. Executing Query - Creation <?php mysql_query(“create database if not exists ‘abc’”,$con); mysql_use_db(‘abc’); mysql_query(“create table if not exists trainee(name varchar(30) primary key, score int(3))engine=myisam”); ?>
  4. 4. Executing Query - Insert <?php $q = “((‘Trainee1’, 20), (‘Trainee2’,’40’), (‘Trainee3, 60))”; mysql_query(“insert into abc.trainee values $q”); echo mysql_error(); ?> name score trainee1 20 trainee2 40 tainee3 60

×