hoopplaya4 Posted November 11, 2008 Share Posted November 11, 2008 Okay, so I've been trying to figure this one out for the last few hours, and I can't tell what's wrong. I'm trying to Update my database from a few fields, and it doesn't update. Here's my form fields: $sql = "SELECT * FROM tblPractices WHERE (practiceID = " . $_GET["num"] . ")"; require("../connection.php"); $rs = mysql_db_query($DBname,$sql,$link); if ($rs) { while ($row=mysql_fetch_array($rs)){ print("<h1>Edit Practice - ".$row['practiceDate'] ."</h1>" ); print("<div id='communicate'>"); ?> <form class='uniForm' enctype='multipart/form-data' action="updatepractice.php" method='POST'> <? print("<table width='80%' cellpadding='0'"); print("<div class='ctrlHolder'>"); print("<fieldset>"); print("<legend><a href=uploads/".$row['practiceFile'] ."><img src='../images/dl.png' border='0' /></a> " ); print("<a href=uploads/".$row['practiceFile'] .">Download File</a></legend>" ); print("<div style='float:left'>"); print("<p ><i>Posted By:</i> ".$row['practicePostby'] ."</p>"); print("</div>"); print(" </fieldset>"); print("</div>"); print("<div class='ctrlHolder'>"); print("<fieldset>"); print("<legend>Coach's Comments</legend>"); print("<textarea id='styled' cols='115' rows='6' wrap='soft' type='text' name = 'email'>".$row['practiceComments']."</textarea>"); print("</fieldset>"); print("</div>"); print("<div class='ctrlHolder'>"); print("<fieldset>"); print("<legend>Private Comments</legend>"); print("<textarea id='styled' cols='115' rows='6' wrap='soft' type='text' name = 'phone'>".$row['practicePrivate']."</textarea>"); print("</fieldset>"); print("</div>"); print("<div class='buttonHolder'>"); print("<fieldset>"); print("<br><br>"); print("<input class='submitButton' type='submit' name='submit' value='Add Practice'>"); print("<div style='float:left'>"); print(" « <a href='#' onClick='history.go(-1);return true;'>Go Back</a>" ); print("</div>"); print("</fieldset>"); print("</div>"); print("</table>"); ?> <input type="hidden" name="pid" value="<?= $_GET["num"] ?>"><? print("</form>"); print("</div>"); } //end while } // end if And here's the php: <? require("../connection.php"); $rs = mysql_db_query($DBname,$sql,$link); $comments=$_POST['email']; $private=$_POST['phone']; $practiceid=$_POST['pid']; $sql = "UPDATE tblPractices SET practiceComments = '$comments' "; $sql .= "practicePrivate = '$private'" ; $sql .= "where practiceID = '$practiceid'"; echo $sql; if ($rs) { print ("<p>Complete!</p>"); } // end if else {print ("<br><br>Practice was not updated. <br>\n"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/132227-update-mysql-tables/ Share on other sites More sharing options...
DeanWhitehouse Posted November 11, 2008 Share Posted November 11, 2008 For christ sake, why don't people ever try and debug on there own. Add or die(mysql_error()); to the statements. Quote Link to comment https://forums.phpfreaks.com/topic/132227-update-mysql-tables/#findComment-687331 Share on other sites More sharing options...
premiso Posted November 11, 2008 Share Posted November 11, 2008 <?php require("../connection.php"); $rs = mysql_db_query($DBname,$sql,$link); $comments=$_POST['email']; $private=$_POST['phone']; $practiceid=$_POST['pid']; $sql = "UPDATE tblPractices SET practiceComments = '$comments', "; $sql .= "practicePrivate = '$private' " ; $sql .= "where practiceID = '$practiceid'"; echo $sql; if ($rs) { print ("<p>Complete!</p>"); } // end if else {print ("<br><br>Practice was not updated. <br>\n"); } ?> You were missing a , and a space before the where. Quote Link to comment https://forums.phpfreaks.com/topic/132227-update-mysql-tables/#findComment-687332 Share on other sites More sharing options...
hoopplaya4 Posted November 11, 2008 Author Share Posted November 11, 2008 Thanks for the reply fellas. Well, I tried to make the grammatical changes, and added the debug, and it's still not working. The debug error I'm getting is "Query was empty." I think this has to do with me passing the ID. Any IDeas? (Sorry for the pun). Quote Link to comment https://forums.phpfreaks.com/topic/132227-update-mysql-tables/#findComment-687469 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.