How to Connect and Insert Record to MYSQL using PHP?

Answers were Sorted based on User's Feedback



How to Connect and Insert Record to MYSQL using PHP?..

Answer / mukesh bisht

<?php
//var_dump($_POST);
//die();
$link=mysql_connect("localhost","root","");
$db=mysql_select_db("emp",$link);
$id=$_POST['id'];
$name=$_POST['name'];
$age=$_POST['age'];
$phone=$_POST['phone'];
$salary=$_POST['salary'];
$address=$_POST['address'];


$query="insert into db(id,name,age,phone,salary,address)
values
('".$id."','".$name."','".$age."','".$phone."','".$salary."'
,'".$address."')";
//echo $query;
mysql_query($query);
echo "<B></B>DATA ADDED SUCCESSFULLY<B></B>";
?>

Is This Answer Correct ?    22 Yes 8 No

How to Connect and Insert Record to MYSQL using PHP?..

Answer / satyajit das

$conn = mysql_connect("localhost","root","");
mysql_select_db("database_name",$conn); // Connection....

if($hh){

$res = mysql_query("insert into `table`(`all
paramaeters of table`)values('','','')");

}
$res1 = mysql_query("select * from `table`");

// Insert Module....

Is This Answer Correct ?    16 Yes 6 No

How to Connect and Insert Record to MYSQL using PHP?..

Answer / pinal

<?php

$Con = mysql_connect("$vHostName","$vUserName","$vPassword");

if(!$Con ) {
die("<html><script language = 'Javascript'>alert('unable
to connecet to the db ... bcause'". mysql_error().
")</script></html>");
}

mysql_select_db("$dbName",$Con);
?>

Is This Answer Correct ?    1 Yes 0 No

How to Connect and Insert Record to MYSQL using PHP?..

Answer / sudhanshu

To
Connect="$dblink=mysql_connect("127.0.0.1","mediamagick","mediamagick");
$db_conn=mysql_select_db("mediamagick_italy",$dblink)or
die("could not connect");"
And To Insert = "Select (Field Names) values (values to
insert )";

Is This Answer Correct ?    4 Yes 5 No

How to Connect and Insert Record to MYSQL using PHP?..

Answer / anirban paul

<?php
->connection parts-------
mysql_connect("<webser-name>","user-name","password-name");
mysql_select_db("<database-name>");
->insertion parts--------
$r=mysql_query("insert into <table-name> values(fild
name)");
if($r)
{
print "<h1>insert successfully";
}
else
{
print"<h1>insert not successfully";
}

Is This Answer Correct ?    3 Yes 6 No

How to Connect and Insert Record to MYSQL using PHP?..

Answer / ra-j-an

<?php

$dbCon = mysql_connect("$vHostName","$vUserName","$vPassword");

if(!$dbCon ) {
die("<html><script language = 'Javascript'>alert('unable
to connecet to the db ... bcause'". mysql_error().
")</script></html>");
}

mysql_select_db("$dbName",$dbCon);
?>

Is This Answer Correct ?    2 Yes 5 No

Post New Answer

More PHP Code Interview Questions

How can i know that how many user are visited to my page in php?

0 Answers   NIIT,


What is the best way to make wordpress plugin

0 Answers   TCS,


can we pass variable in array to traverse it?

0 Answers  


If i have an array $string = array(1,2,6,2,9,6,7,3,1,2); How can i get only unique values from it? Array ( [0] => 1 [1] => 2 [2] => 6 [4] => 9 [6] => 7 [7] => 3 )

2 Answers  


What is 301 redirects in php? When are we used 301 redirects in our projects?

0 Answers   NIIT,






How can import database to mysql using php code?

1 Answers   Wipro,


What is main difference between Cookie and Cache?

3 Answers   NIIT, Wipro,


What is used of phpinfo() function in php?

1 Answers  


How to Connect and Insert Record to MYSQL using PHP?

6 Answers  


Hey, any expert here can help me to creat php code. I want php code to calculate like below. input :12 April 1974 then perform this calculation: 12 + 4 + 1974 = 1990 1 + 9 + 9 + 0 = 19 1 + 9 = 10 1 + 0 = 1(final answer) this code i just want to used to share the personality from date of birth. The input come from user, base on user input, then php will calculate like above, and, the final answer will use do display the person attitude. example, final answer = 1, display patient person final answer = 2, will display hard working person

0 Answers  


I have array like $array = array(1, "hello", 1, "world", "hello"); if i want the following output then how can i do this? Array ( [1] => 2 [hello] => 2 [world] => 1 )

2 Answers   NIIT,


How can export database using php code?

0 Answers  


Categories
  • PHP Code Interview Questions PHP Code (33)
  • JSP Code Interview Questions JSP Code (6)
  • ASP Code Interview Questions ASP Code (5)
  • CGI Perl Code Interview Questions CGI Perl Code (3)
  • JavaScript Code Interview Questions JavaScript Code (63)
  • VB Script Code Interview Questions VB Script Code (20)
  • Shell Script Code Interview Questions Shell Script Code (31)
  • Python Code Interview Questions Python Code (34)
  • WinRunner Code Interview Questions WinRunner Code (1)
  • HTML DHTML XHTML Code Interview Questions HTML DHTML XHTML Code (13)
  • XML Interview Questions XML (43)
  • Scripts_Markup Code AllOther Interview Questions Scripts_Markup Code AllOther (5)