S A N T A Posted April 28, 2008 Share Posted April 28, 2008 ok so I'm working on a blog and im adding the edit button but for some reason when i click the "Update Entry!" button it goes to the right page and everything but it doesn't update it? heres the code: <?php session_start(); require("config.php"); if(isset($_SESSION['USERNAME']) == FALSE) { header("Location: " . $config_basedir); } $db = mysql_connect($dbhost, $dbuser); mysql_select_db($dbdatabase, $db); if(isset($_GET['id']) == TRUE) { if(is_numeric($_GET['id']) == FALSE) { $error = 1; } if($error == 1) { header("Location: " . $config_basedir); } else { $validentry = $_GET['id']; } } else { $validentry = 0; } if($_POST['submit']) { $sql = "UPDATE entries SET cat_id = " . $_POST['cat'] . ", sebject = '" . $_POST['subject'] ."', body = '" . $_POST['body'] . "' WHERE id = " . $validentry . ";"; mysql_query($sql); header("Location: " . $config_basedir . "/viewentry.php?id=" . $validentry); } else { require("header.php"); $fillsql = "SELECT * FROM entries WHERE id = " . $validentry . ";"; $fillres = mysql_query($fillsql); $fillrow = mysql_fetch_assoc($fillres); ?> <h1>Update entry</h1> <form action="<?php echo $SCRIPT_NAME . "?id=" . $validentry; ?>" method="post"> <table> <tr> <td>Category</td> <td> <select name="cat"> <?php $catsql = "SELECT *FROM categories;"; $catres = mysql_query($catsql); while($catrow= mysql_fetch_assoc($catres)) { echo "<option value='" . $catrow['id'] . "'"; if($catrow['id'] == $fillrow['cat_id']) { echo " selected"; } echo ">" . $catrow['cat'] . "</option>"; } ?> </select> </td> </tr> <tr> <td>Subject</td> <td><input type="text" name="subject" value="<?php echo $fillrow['subject']; ?>"> </td> </tr> <tr> <td>Body</td> <td><textarea name="body" rows="10" cols="50"><?php echo $fillrow['body']; ?></textarea></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" value="Update Entry!"></td> </tr> </table> </form> <?php } require("footer.php"); ?> thanks in advance Quote Link to comment Share on other sites More sharing options...
paul2463 Posted April 28, 2008 Share Posted April 28, 2008 change this line mysql_query($sql); to this mysql_query($sql) or die ("Error in query" . mysql_error()); and see if it throws an error for you Quote Link to comment Share on other sites More sharing options...
soycharliente Posted April 28, 2008 Share Posted April 28, 2008 sebject = ??? Quote Link to comment Share on other sites More sharing options...
S A N T A Posted April 28, 2008 Author Share Posted April 28, 2008 it gives me this error: Error in queryUnknown column 'sebject' in 'field list' Quote Link to comment Share on other sites More sharing options...
paul2463 Posted April 28, 2008 Share Posted April 28, 2008 change "sebject" in your query to "subject" as Charlie pointed out and my error code pointed out to you Quote Link to comment Share on other sites More sharing options...
S A N T A Posted April 28, 2008 Author Share Posted April 28, 2008 Lol spelling my bad. Thanks for the help! Quote Link to comment Share on other sites More sharing options...
paul2463 Posted April 28, 2008 Share Posted April 28, 2008 always always always put the or die ("Error in query " . mysql_error()); on the end of your query execution call, it points the way to so many silly little faults like this one (silly little faults incorporate spelling errors, wrong punctuation and the like) 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.