tabatsoy Posted April 2, 2008 Share Posted April 2, 2008 when i press on the submit button a warning appears Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in c:\program files\wamp\www\exam\dummy.php on line 40 firstname: lastname: TotalScore: and i can't figure out what's wrong please help. here is my code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <? $db = mysql_connect("localhost"); mysql_select_db("examination",$db); if(!isset($cmd)) { $result = mysql_query("select * from examinee order by examineeID"); while($r=mysql_fetch_array($result)) { $firstname=$r["firstname"]; $lastname = $r["lastname"]; $math = $r["math"]; $english = $r["english"]; $logic = $r["logic"]; $totalScore = $r["TotalScore"]; $examineeID=$r["examineeID"]; echo $firstname, $lastname, $math, $english, $logic, $totalScore; echo "<a href='dummy.php?cmd=edit&id=$examineeID'> Edit</a><br>"; } } ?> <? if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit") { if (!isset($_POST["submit"])) { $id = $_GET["examineeID"]; $result = mysql_query( "SELECT * FROM examinee WHERE examineeID=$id"); $myrow = mysql_fetch_array($result); ?> <form action="dummy.php" method="post"> <input type=hidden name="id" value="<?php echo $myrow["examineeID"] ?>"> firstname:<INPUT TYPE="TEXT" NAME="firstname" VALUE="<?php echo $myrow["firstname"] ?>" SIZE=30><br> lastname:<input type="text" NAME="lastname" value="<? echo $myrow["lastname"] ?>"size =30 ><br> TotalScore:<INPUT TYPE="TEXT" NAME="totalscore" VALUE="<?php echo $myrow["TotalScore"] ?>" SIZE=30><br> <input type="hidden" name="cmd" value="edit"> <input type="submit" name="submit" value="submit"> </form> <? } ?> <? if ($_POST["$submit"]) { $firstname = $_POST["firstname"]; $lastname = $_POST["lastname"]; $totalScore = $_POST["TotalScore"]; $sql = "UPDATE examnee SET firstname='$firstname',lastname='$lastname',TotalScore='$TotalScore' WHERE examineeID=$id"; $result = mysql_query($sql); echo "Thank you! Information updated."; } } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/99125-solved-help-in-error-handling/ Share on other sites More sharing options...
cyrixware Posted April 2, 2008 Share Posted April 2, 2008 firstname:<INPUT TYPE="TEXT" NAME="firstname" VALUE="<?php echo $myrow["firstname"]; ?>" SIZE=30><br> lastname:<input type="text" NAME="lastname" value="<? echo $myrow["lastname"]; ?>"size =30 ><br> TotalScore:<INPUT TYPE="TEXT" NAME="totalscore" VALUE="<?php echo $myrow["TotalScore"]; ?>" SIZE=30><br> Check your code. add semi color after the lines..... Link to comment https://forums.phpfreaks.com/topic/99125-solved-help-in-error-handling/#findComment-507208 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.