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 Quote Link to comment Share on other sites More sharing options...
inversesoft123 Posted November 3, 2010 Share Posted November 3, 2010 what is the errror ? Quote Link to comment 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 ............................. Quote Link to comment 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>"; Quote Link to comment 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"; Quote Link to comment 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"; ?> Quote Link to comment 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']'"); Quote Link to comment 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']."'"); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.