468,308 Members | 1,220 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,308 developers. It's quick & easy.

Discussion about updationof records in php

Hello friends,
I am working in php .i have one problem regarding to updation .
Code for updation i use is :
<?php
$fname = $_POST['fname'];
$lname = $_POST['lastname'];
$find = $_POST['age'];
echo "$find"; ?>
<table width="200" border="0" cellpadding="0" cellspacing="0" bordercolor="#666666" bgcolor="#FFFFFF"/>
<tr bordercolor="#666666" bgcolor="#99FFCC">
<td bordercolor="#333333" border ="1"><?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="root"; // Mysql password
$db_name="projectdb"; // Database name
// Connect to server and updatedatabase.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sqls ="UPDATE person SET Age = '$find'
WHERE FirstName = '$lname ' AND LastName = '$fname'";
$result = mysql_query($sqls);
if($result == '1')
echo"Record updated suceefully";
else
echo"sorry";
?>
It is not showing error but records are not updated.
Please suggest me.As I am beginners.So please suggest me.
Jul 20 '07 #1
2 943
abertay
10
Hello friends,
I am working in php .i have one problem regarding to updation .
Code for updation i use is :
<?php
$fname = $_POST['fname'];
$lname = $_POST['lastname'];
$find = $_POST['age'];
echo "$find"; ?>
<table width="200" border="0" cellpadding="0" cellspacing="0" bordercolor="#666666" bgcolor="#FFFFFF"/>
<tr bordercolor="#666666" bgcolor="#99FFCC">
<td bordercolor="#333333" border ="1"><?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="root"; // Mysql password
$db_name="projectdb"; // Database name
// Connect to server and updatedatabase.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sqls ="UPDATE person SET Age = '$find'
WHERE FirstName = '$lname ' AND LastName = '$fname'";
$result = mysql_query($sqls);
if($result == '1')
echo"Record updated suceefully";
else
echo"sorry";
?>
It is not showing error but records are not updated.
Please suggest me.As I am beginners.So please suggest me.

Hi punitshrivastava,
i've gone through your code....

replace this query
$dbconnection=mysql_connect($host,$username,$passw ord) or die("cannot connect");

and also
$result = mysql_query($sqls,$dbconnection);

if you still can't get the desired result try to echo every sql statement.
Jul 20 '07 #2
Hi abertay,
Thanks it works.

Hi punitshrivastava,
i've gone through your code....

replace this query
$dbconnection=mysql_connect($host,$username,$passw ord) or die("cannot connect");

and also
$result = mysql_query($sqls,$dbconnection);

if you still can't get the desired result try to echo every sql statement.
Jul 20 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

13 posts views Thread by Robert Smith | last post: by
5 posts views Thread by stenknz | last post: by
21 posts views Thread by Rune Steffensen | last post: by
3 posts views Thread by John Rivers | last post: by
reply views Thread by Harry Smith | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.