Jump to content

Update MySql Tables


hoopplaya4

Recommended Posts

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");

}


?>

 

Link to comment
Share on other sites

<?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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.