By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,453 Members | 961 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,453 IT Pros & Developers. It's quick & easy.

Discussion about updationof records in php

P: 22
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
Share this Question
Share on Google+
2 Replies


P: 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

P: 22
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.