kurbitur Posted November 13, 2011 Share Posted November 13, 2011 I have a small (42 hours) problem with my code trying to edit article (edit.php) ... should be basic When I choose article to edit the data appears in the forms and when hit "update" it returns no error, but the date didn´t changes in the db less talk - more code .... anyone who can spot what I am doing wrong? <?PHP connection to database blah blah ?> <?php if(isset($_POST['update'])) { //here the id that we post is the same id that we get from url //id indicates the id of this data which we are editing //id is unique and a particular id is associated with particular data $newsid = $_POST['newsid']; $date=$_POST['date']; $time=$_POST['time']; $location=$_POST['location']; //updating the table $result=mysql_query("UPDATE news SET date='$date',time='$time',location='$location', WHERE newsid=$newsid"); //redirectig to the display page. In our case, it is index.php header("Location: listNews.php"); } } ?> <?php //for displaying data of this particular data //getting id from url $newsid = $_GET['newsid']; //selecting data associated with this particular id $result=mysql_query("select * from news where newsid=$newsid"); while($res=mysql_fetch_array($result)) { $date = $res['date']; $time = $res['time']; $location = $res['location']; } ?> ---- form ---- <form method="post" action="editNews.php" name="form1"> each form has <input type="text" name="headline" value="<?php echo $location;?>" id="UserName"> and <input type="hidden" name="newsid" value=<?php echo $_GET['newsid'];?> <input name="update" type="submit" value="update" /> Most likely there is something that I don´t see but "seeing" has taken almost 2 days now Link to comment https://forums.phpfreaks.com/topic/251076-stupid-problem-with-basic-editnewsphp/ Share on other sites More sharing options...
Drummin Posted November 14, 2011 Share Posted November 14, 2011 You are using name="headline" for your textarea but on processing you are using $location=$_POST['location'];. Also I highly recommend using http://php.net/manual/en/function.mysql-real-escape-string.php to protect your DB. Link to comment https://forums.phpfreaks.com/topic/251076-stupid-problem-with-basic-editnewsphp/#findComment-1287908 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.