Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

LAMP_TRAINING_SESSION_8

933 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
  • Be the first to comment

  • Be the first to like this

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

×