mtvaran Posted November 3, 2010 Share Posted November 3, 2010 could anyone pls check this coding? i need to display the data from database into the text field for editing then submit to the existing database. mysql_select_db("uni", $con); $sql=mysql_query("select * from student"); $res=0; while($row=mysql_fetch_array($sql)) { if($row['StudentID']==$_POST["sid"]) { ?> <form id="form2" name="form2" method="post" action="update.php"> <h2><p><?php echo "StudentID :" ?> <input type="text" name="sid" id="sid" value="<?php echo"".$row['StudentID'] ?>" /> <p><?php echo "StudentName :" ?> <input type="text" name="stname" id="stname" value="<?php echo"".$row['StudentName'] ?>" /> </p> <?php $res=1; } }?> <h2> <?php if($res==0) { echo "Please enter the Correct ID. "; } update.php mysql_select_db("uni", $con); mysql_query("UPDATE student SET StudentID = .$row['StudentID'] WHERE student.StudentID = '.$row['StudentID']'"); mysql_query("UPDATE student SET StudentName = .$row['StudentName'] WHERE student.StudentID = '.$row['StudentID']'"); echo "Successfully Edited"; //submit button Link to comment https://forums.phpfreaks.com/topic/217681-updata-the-data-into-the-text-field/ Share on other sites More sharing options...
inversesoft123 Posted November 3, 2010 Share Posted November 3, 2010 what is the errror ? Link to comment https://forums.phpfreaks.com/topic/217681-updata-the-data-into-the-text-field/#findComment-1129974 Share on other sites More sharing options...
mtvaran Posted November 3, 2010 Author Share Posted November 3, 2010 it says something like, Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in ............................. Link to comment https://forums.phpfreaks.com/topic/217681-updata-the-data-into-the-text-field/#findComment-1129976 Share on other sites More sharing options...
inversesoft123 Posted November 3, 2010 Share Posted November 3, 2010 it says something like, Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in ............................. why are you hiding error message under ............................. we need line number anyways change this <h2><p><?php echo "StudentID :" ?> <input type="text" name="sid" id="sid" value="<?php echo"".$row['StudentID'] ?>" /> <p><?php echo "StudentName :" ?> <input type="text" name="stname" id="stname" value="<?php echo"".$row['StudentName'] ?>" /> </p> to echo "<h2><p>StudentID : <input type=\"text\" name=\"sid\" id=\"sid\" value=\"$row['StudentID']\" />"; echo "<p>StudentName :<input type=\"text\" name=\"stname\" id=\"stname\" value=\"$row['StudentName'] \" /> </p>"; Link to comment https://forums.phpfreaks.com/topic/217681-updata-the-data-into-the-text-field/#findComment-1129979 Share on other sites More sharing options...
mtvaran Posted November 3, 2010 Author Share Posted November 3, 2010 hi, as i mentioned the line , there is an error cud u pls hav a look again... mysql_select_db("uni", $con); $sql=mysql_query("select * from student"); $res=0; while($row=mysql_fetch_array($sql)) { if($row['StudentID']==$_POST["sid"]) { ?> <form id="form2" name="form2" method="post" action="editing.php"> <?php echo "<p>StudentID : <input type=\"text\" name=\"sid\" id=\"sid\" value=\"$row['StudentID']\" />"; //. this line error echo "<p>StudentName :<input type=\"text\" name=\"sname\" id=\"sname\" value=\"$row['StudentName'] \" /> </p>"; $res=1; } } if($res==0) { echo "Please enter the Correct ID. "; } mysql_close($con); ?> update.php <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("uni", $con); mysql_query("UPDATE student SET StudentID = .$row['StudentID'] WHERE student.StudentID ='.$row['StudentID']'"); mysql_query("UPDATE student SET StudentName = .$row['StudentName'] WHERE student.StudentID ='.$row['StudentID']'"); echo "Successfully Edited"; Link to comment https://forums.phpfreaks.com/topic/217681-updata-the-data-into-the-text-field/#findComment-1129997 Share on other sites More sharing options...
inversesoft123 Posted November 3, 2010 Share Posted November 3, 2010 <?php mysql_select_db("uni", $con); $sql=mysql_query("select * from student"); $res=0; while($row=mysql_fetch_array($sql)) { if($row['StudentID']==$_POST["sid"]) { ?> <form id="form2" name="form2" method="post" action="editing.php"> <?php $studentid = $row['StudentID']; $studentname = $row['StudentName']; echo "<p>StudentID: <input type=\"text\" name=\"sid\" id=\"sid\" value=\"$studentid\"/>"; echo "<p>StudentName :<input type=\"text\" name=\"sname\" id=\"sname\" value=\"$studentname \" /> </p>"; $res=1; } } if($res==0) { echo "Please enter the Correct ID. "; } mysql_close($con); ?> update.php <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("uni", $con); mysql_query("UPDATE student SET StudentID = .$row['StudentID'] WHERE student.StudentID ='.$row['StudentID']'"); mysql_query("UPDATE student SET StudentName = .$row['StudentName'] WHERE student.StudentID ='.$row['StudentID']'"); echo "Successfully Edited"; ?> Link to comment https://forums.phpfreaks.com/topic/217681-updata-the-data-into-the-text-field/#findComment-1130001 Share on other sites More sharing options...
mtvaran Posted November 3, 2010 Author Share Posted November 3, 2010 it says some error as i mentioned mysql_query("UPDATE student SET StudentID = .$row['StudentID']//Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' WHERE student.StudentID ='.$row['StudentID']'"); mysql_query("UPDATE student SET StudentName = .$row['StudentName'] WHERE student.StudentID ='.$row['StudentID']'"); Link to comment https://forums.phpfreaks.com/topic/217681-updata-the-data-into-the-text-field/#findComment-1130003 Share on other sites More sharing options...
BlueSkyIS Posted November 3, 2010 Share Posted November 3, 2010 improper concatenation. mysql_query("UPDATE student SET StudentID = '".$row['StudentID']."' WHERE student.StudentID = '".$row['StudentID']."'"); mysql_query("UPDATE student SET StudentName = '".$row['StudentName']."' WHERE student.StudentID = '".$row['StudentID']."'"); Link to comment https://forums.phpfreaks.com/topic/217681-updata-the-data-into-the-text-field/#findComment-1130094 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.