How to Connect and Insert Record to MYSQL using PHP?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
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 |
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 |
what is main difference between array_push and array_pop?
What is the best way to make wordpress plugin
How can get all database name using Php and Sql?
What is used of serialize and unserialize in php?
Given a string=”me,I,myself”; .Using javascript only create an array out of this string and then send a POST request to the url “record.php” without reloading the page. The post key parameters should be n1,n2 and n3 respectively.
How can get current system time continuously without refresh of page?
hi sir actually i use now day's ajax but i m having problem my opinion i thing this code is right becuse i make code for my side validation with ajax in php so but it is not run complete i m posting my code pls confirm and clear my some mistake and return send me with informatiom what was error so next time i will be care fully so i m sending u but replay so quick because tomorrow i have to present it some where,frist one is index.php and second is show.php show.php is database connectivity for testing
Given a string=”me,I,myself”; .Using javascript only create an array out of this string and then send a POST request to the url “record.php” without reloading the page. The post key parameters should be n1,n2 and n3 respectively.
How can restrict user to type upto 8 characters in textbox in php?
What is difference between in_array and array_search?
How many frameworks are in php?
How can export database using php code?