LostNights Posted May 10, 2006 Share Posted May 10, 2006 It wont update my information in the DB[code]<?php$id = $_GET['id']; if (isset($_POST['submitbutton'])) {mysql_connect('localhost','user','user') or die ("Cannot connect to server");mysql_select_db("photodirectory") or die ("Cannot connect to database");$query = "UPDATE corporatelist SET firstname='$_POST[firstname]', lastname='$_POST[lastname]',title='$_POST[title]',department='$_POST[department]',office='$_POST[office]',phone='$_POST[phone]' WHERE sku = '".$id."' ";$result = mysql_query($query); if (!$result) { echo "There was a problem with your entry. <a href='infoupdate2.php'>Back</a>"; } else { echo "Your information has been changed."; } } else {?><?php echo $id; ?><form action="infoupdate2.php" method="post"><p>First Name: <input type="text" maxlength="30" size="32" name="firstname" /></p><p>Last Name: <input type="text" maxlength="30" size="32" name="lastname" /></p><p>Job Title: <input type="text" maxlength="55" size="57" name="title" /></p><p>Department: <input type="text" maxlength="18" size="20" name="department" /></p><p>Office: <input type="text" maxlength="4" size="6" name="office" /></p><p>Phone Number: <input type="text" maxlength="4" size="6" name="phone" /></p><input type="submit" value="Enter Employee Information" name="submitbutton" /></form><?php } ?>[/code] Quote Link to comment Share on other sites More sharing options...
fenway Posted May 10, 2006 Share Posted May 10, 2006 Won't update how? What's the mysql error that you're getting? Quote Link to comment Share on other sites More sharing options...
LostNights Posted May 10, 2006 Author Share Posted May 10, 2006 No error, just cycles to the "Your info has been updated" line, but it doesnt update that line in the database.Could it be the variable from the other page? Its just a link variable. the ID echo's out fine. Quote Link to comment Share on other sites More sharing options...
LostNights Posted May 10, 2006 Author Share Posted May 10, 2006 When I change[code]$query = "UPDATE corporatelist SET firstname='$_POST[firstname]', lastname='$_POST[lastname]',title='$_POST[title]',department='$_POST[department]',office='$_POST[office]',phone='$_POST[phone]' WHERE sku = '".$id."' ";[/code]to[code]$query = "UPDATE corporatelist SET firstname='$_POST[firstname]', lastname='$_POST[lastname]',title='$_POST[title]',department='$_POST[department]',office='$_POST[office]',phone='$_POST[phone]' WHERE lastname = 'Benko' ";[/code]That changes it for the person whos last name is Benko, so its a problem with the variable. Quote Link to comment Share on other sites More sharing options...
ryanlwh Posted May 10, 2006 Share Posted May 10, 2006 [code] action="infoupdate2.php?id=<?=$id?>" [/code] Quote Link to comment Share on other sites More sharing options...
LostNights Posted May 10, 2006 Author Share Posted May 10, 2006 action="infoupdate2.php?id=<?php =$id ?>" gave a parse erroraction="infoupdate2.php?id=<?php $id ?>" didnt make a difference Quote Link to comment Share on other sites More sharing options...
fenway Posted May 10, 2006 Share Posted May 10, 2006 If you echo the query, I'll bet that you won't see a valid ID in the query string. 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.