Worstof Posted February 13, 2008 Share Posted February 13, 2008 Trying to update a record once the user has changed information in the fields. The unique user id is being passed correctly, the new information is in the variables, but for some reason the UPDATE command is not working. I've made sure the id that is being passed is the same as the id it should be able to find in the database in order to complete the UPDATE command. But, no luck. I get the failure message each time. I've got a lot of echo and other commands in there to show me the id values, so please ignore that extra code. I've struggled for hours...please help! Thanks. <html> <head> <title></title> </head> <body bgcolor="#FFFFFF"> <?php //Connect to DB server $dbcnx=@mysql_connect('localhost', 'myusername', 'mypasswd'); if (!$dbcnx) { exit('<p>Unable to connect to server</p>');} //Select the rsvp database if (!@mysql_select_db('mydb')) { exit('<p> Unable to connect to database</p>'); } if (isset($_POST['lastname'])): //The fields have been updated $lastname =$_POST["lastname"]; $firstname=$_POST["firstname"]; $email=$_POST["email"]; $phone=$_POST["phone"]; $tour=$_POST["tour"]; $lunch=$_POST["lunch"]; $ceremony=$_POST["ceremony"]; $numinparty=$_POST["numinparty"]; $lodging=$_POST["lodging"]; $arrival=$_POST["arrival"]; $method=$_POST["method"]; $departure=$_POST["depart"]; $vehicle=$_POST["vehicle"]; $comments=$_POST["comments"]; $rsvpid=$_POST["id"]; $rsvpedit=@mysql_query( "SELECT id FROM rsvp WHERE id='$rsvpid'"); if (!rsvpedit) { exit('<p>Error finding the RSVP</p>');} $rsvpedit=mysql_fetch_array($rsvpedit); $id2=$rsvpedit['id']; echo $id2; echo $rsvpid; echo $lastname; $sql= "UDPATE rsvp SET lastname='$lastname' WHERE id='$rsvpid'"; // firstname='$firstname', // email='$email', // phone='$phone', // tour='$tour', // lunch='$lunch', // ceremony='$ceremony', // numinparty='$numinparty', // lodging='$lodging', // arrival='$arrival', // departure='$departure', // method='$method', // vehicle='$vehicle', // comments='$comments' if (@mysql_query($sql)) { echo '<p>RSVP successfully updated</p>'; } else { echo "<p>RSVP not updated! ID code: $rsvpid</p>"; } ?> <p><a href="adduser.php">Return</a></p> <?php else: //Allow user to edit author $id=$_GET['id']; $rsvpedit=@mysql_query( "SELECT id,lastname, firstname, email,phone,tour, lunch,ceremony,numinparty,lodging,arrival,departure,method,vehicle,comments FROM rsvp WHERE id='$id'"); if (!rsvpedit) { exit('<p>Error finding the RSVP</p>');} $rsvpedit=mysql_fetch_array($rsvpedit); $id2=$rsvpedit['id']; $lastname=$rsvpedit['lastname']; $firstname=$rsvpedit['firstname']; $email=$rsvpedit['email']; $phone=$rsvpedit['phone']; $tour=$rsvpedit['tour']; $lunch=$rsvpedit['lunch']; $ceremony=$rsvpedit['ceremony']; $numinparty=$rsvpedit['numinparty']; $lodging=$rsvpedit['lodging']; $arrival=$rsvpedit['arrival']; $departure=$rsvpedit['departure']; $method=$rsvpedit['method']; $vehicle=$rsvpedit['vehicle']; $comments=$rsvpedit['comments']; ?> <table bgcolor=#000000 valign=top align=center border=0><tr><td bgcolor=#000000><table cellpadding=4 bgcolor=#ffffff cellspacing=2 border=0> <Tr><th>RSVP for Lt Col Franklin's luncheon</th></tr><tr><td> <FORM ACTION="<?php echo $_SERVER['PHP_SELF'];?>" METHOD="post" > <INPUT TYPE=hidden NAME="id" value="<?php echo $id; ?>" /><Br> Last Name: <INPUT TYPE=text MAXLENGTH=70 NAME="lastname" value="<?php echo $lastname; ?>" /><Br> First Name: <INPUT TYPE=text MAXLENGTH=70 NAME="firstname" SIZE=20 value="<?php echo $firstname; ?>" /><Br> E-mail: <INPUT TYPE=TEXT MAXLENGTH=20 NAME="email" value="<?php echo $email; ?>" /><Br> Phone: <INPUT TYPE=TEXT NAME="phone" value="<?php echo $phone; ?>" /> <Br> Pentagon Tour: <INPUT TYPE=CHECKBOX name="tour" value="<?php echo $tour; ?>" /><Br> Attending Lunch: <Input type=checkbox name="lunch" value="<?php echo $lunch; ?>" /><br> Attending Retirement Ceremony: <Input type=checkbox name="ceremony" value="<?php echo $ceremony; ?>" /><br> Number in Party (include yourself):<input type=text name=numinparty value="<?php echo $numinparty; ?>" /><br> Do you need lodging?:<input type=checkbox name="lodging" value="<?php echo $lodging; ?>" /><br> When do you arrive (date/time): <input type=text name="arrival" value="<?php echo $arrival; ?>" /><br> Method of transportation:<input type=text name="method" value="<?php echo $method; ?>" /><br> When do you depart (date/time):<input type=text name="departure" value="<?php echo $departure; ?>" /><br> Vehicle tag info for Pentagon parking pass (if needed): <input type=text name="vehicle" value="<?php echo $vehicle; ?>" /><br> Other comments:<input type=text maxlength=200 name="comments" size=200 value="<?php echo $comments; ?>" /><br> <INPUT TYPE=submit VALUE="Submit"> <INPUT type=reset VALUE="Reset Form"></form> </tr></td></table></tr></td></table> <?php echo $id2; ?> <?php endif; ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/90830-cannot-update-a-record/ Share on other sites More sharing options...
cooldude832 Posted February 13, 2008 Share Posted February 13, 2008 all queries in debuggin mode should be written <?php $q = "Select this from `that` where 1"; $r = mysql_query($q) or die(mysql_error()."<Br /><Br / >".$q); ?> Try that on your queries and if it errors report them Link to comment https://forums.phpfreaks.com/topic/90830-cannot-update-a-record/#findComment-465525 Share on other sites More sharing options...
Riparian Posted February 13, 2008 Share Posted February 13, 2008 update is spelt wrong "UDPATE Link to comment https://forums.phpfreaks.com/topic/90830-cannot-update-a-record/#findComment-465531 Share on other sites More sharing options...
Worstof Posted February 13, 2008 Author Share Posted February 13, 2008 My screen name fits....I am the ULTIMATE IDIOT. It's amazing how well php works when you spell the commands correctly... Thanks Rip...it works great now. Link to comment https://forums.phpfreaks.com/topic/90830-cannot-update-a-record/#findComment-465538 Share on other sites More sharing options...
cooldude832 Posted February 13, 2008 Share Posted February 13, 2008 fyi I saw that and was hoping you would discovery it from the natural error reporting I suggested. Link to comment https://forums.phpfreaks.com/topic/90830-cannot-update-a-record/#findComment-465545 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.