Peosan Posted June 12, 2010 Share Posted June 12, 2010 I have this edit news script, everything works, except when I press submit. When I press it, it shows it's been successfully updates, however, the database is unchanged. I've tried but no success. :') Here's the code: <?php include("include/database.php"); if (isset($_POST['submitted'])) { $title = $_POST['title']; $newstext = $_POST['newstext']; $posted = $_POST['posted']; $query2 = "UPDATE news_post SET title='$title', newstext='$newstext', posted='$posted' WHERE id='$id'"; $r2 = mysqli_query($dbc, $query2); echo'<h3>Thank you! The news has been UPDATES successfully! Please wait (3) seconds while we throw you to the index!'; echo "<meta http-equiv=Refresh content=4;url=index.php>"; } elseif(isset($_GET['id'])) { $query = "SELECT * FROM news_post WHERE id='$_GET[id]'"; $r = mysqli_query($dbc, $query); while($myrow = mysqli_fetch_assoc($r)) { $title = $myrow["title"]; $newstext = $myrow["newstext"]; $posted = $myrow["posted"]; ?> Link to comment https://forums.phpfreaks.com/topic/204563-edit-news/ Share on other sites More sharing options...
kenrbnsn Posted June 12, 2010 Share Posted June 12, 2010 Where is $id being set before this statement: <?php $query2 = "UPDATE news_post SET title='$title', newstext='$newstext', posted='$posted' WHERE id='$id'"; ?> Ken Link to comment https://forums.phpfreaks.com/topic/204563-edit-news/#findComment-1071113 Share on other sites More sharing options...
Peosan Posted June 12, 2010 Author Share Posted June 12, 2010 Ahhh, thanks Ken! I added $id = $_POST['id']; before the query and now it works like a charm. Thanks alot. <3 :-) Link to comment https://forums.phpfreaks.com/topic/204563-edit-news/#findComment-1071118 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.