localhost Posted July 12, 2006 Share Posted July 12, 2006 [code]<?phpsession_start();include('../connect.php');$loggedin = $_SESSION['username'];if(!$loggedin){ // IF NOT LOGGED INinclude('login.php');die();}$id = $_GET['id'];$sql = "SELECT * FROM news WHERE id = '$id'";$sqlr = mysql_query($sql) or die(mysql_error());while($row = mysql_fetch_array($sqlr)){$newsid = $row['id'];$newstitle = $row['title'];$newsnews = $row['news'];}if(isset($_POST['submit']) && !empty($_POST['title']) && !empty($_POST['news'])){$title = $_POST['title'];$news = $_POST['news'];$sql2 = "UPDATE news SET title = '$title' AND news = '$news' WHERE id = '$id'";$sqlr2 = mysql_query($sql2) or die(mysql_error());if($sqlr2){echo "<script>window.location=\"../news.php\"</script>";}}?><form action="editnews.php" method="POST"> <p>Title: <input type="text" name="title" value="<?php echo "$newstitle"; ?>"/> <br />News:<BR><textarea name="news" cols="50" rows="20"><?php echo "$newsnews"; ?></textarea> <br /> <input type="submit" name="submit" value="Edit" /></form>[/code]does not update inside the database! any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/14427-wont-edit-the-news-properly/ Share on other sites More sharing options...
play_ Posted July 12, 2006 Share Posted July 12, 2006 are you getting a mysql_error message? Quote Link to comment https://forums.phpfreaks.com/topic/14427-wont-edit-the-news-properly/#findComment-57028 Share on other sites More sharing options...
localhost Posted July 12, 2006 Author Share Posted July 12, 2006 no. Quote Link to comment https://forums.phpfreaks.com/topic/14427-wont-edit-the-news-properly/#findComment-57033 Share on other sites More sharing options...
digitalgod Posted July 13, 2006 Share Posted July 13, 2006 try to echo $id just before the sql statement and make sure that id exists Quote Link to comment https://forums.phpfreaks.com/topic/14427-wont-edit-the-news-properly/#findComment-57035 Share on other sites More sharing options...
localhost Posted July 13, 2006 Author Share Posted July 13, 2006 it does... Quote Link to comment https://forums.phpfreaks.com/topic/14427-wont-edit-the-news-properly/#findComment-57041 Share on other sites More sharing options...
localhost Posted July 13, 2006 Author Share Posted July 13, 2006 anyone please? i need to get this done soon. Quote Link to comment https://forums.phpfreaks.com/topic/14427-wont-edit-the-news-properly/#findComment-57054 Share on other sites More sharing options...
play_ Posted July 13, 2006 Share Posted July 13, 2006 try thisif($sqlr2){echo "success;} else { echo mysql_error();} Quote Link to comment https://forums.phpfreaks.com/topic/14427-wont-edit-the-news-properly/#findComment-57082 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.