hello

Thursday, August 10, 2017

8.Update

1) Connection


//Connection variables -->START

$host = 'localhost';    /*domain name or host path*/
$user = 'root';         /*database username*/
$pass = 'your_db_pass'; /*database password*/ 
$database = 'db_users';    /*database name*/

//Connection variables-->END

2) Connection to Database


/*Create a connection to database*/
$connection = mysql_connect($host, $user, $pass) or die('Connection Failed');

/*Selecting the database based on suplied connection*/
$select_db = mysql_select_db($database, $connection) or die('Connection DB Failed');


3)The Query


/*Make a Query UPDATE*/
$query = "update users_tbl set username='hac101', password='pas123' where username='hac101'";

4) Full Code



//Connection variables -->START

$host = 'localhost';    /*domain name or host path*/
$user = 'root';         /*database username*/
$pass = 'your_db_pass'; /*database password*/ 
$database = 'db_users';    /*database name*/

//Connection variables-->END

/*Create a connection to database*/
$connection = mysql_connect($host, $user, $pass) or die('Connection Failed');

/*Selecting the database based on suplied connection*/
$select_db = mysql_select_db($database, $connection) or die('Connection DB Failed');

/*Make a Query UPDATE*/
$query = "update users_tbl set username='hac101', password='pas123' where username='hac101'";

/*Run the Query*/
$result = mysql_query($query) or die('Query Failed');


     
 

No comments: