emediastudios Posted June 15, 2008 Share Posted June 15, 2008 Quite an easy one for you PHPFREAKS, but not so for me. I'm teaching myself with the help of these forums. Im trying to echo the content in the field 'news' in a text field, and allow the ability to update the record. I have altered a file i had on another site and have got this fay. When i view the page i get "" only in the text box. <?php include_once('includes/include.php'); $password = "s*********"; if($_POST[password] == "" && $_SESSION[passed] != "y"){ $content .= "<form method='post' action='admin.php'><input type='password' name='password' value='password'><input type=submit></form>"; } else if($_POST[password] != ""){ if($password == $_POST[password]){ $_SESSION[passed] = "y"; } else{ echo "<script>window.location = 'admin.php';</script>"; } } if($_SESSION[passed] == "y"){ $content .= '<form id="form1" name="form1" method="post" action=""> <table width="500" border="0" align="center"> <tr> <td colspan="2"><label> </label> <div align="center">Edit News</div></td> </tr> <tr> <td> </td> <td><div align="center"> <textarea name="ttnews" id="ttnews" cols="55" rows="10">"'.$ttnews[news].'"</textarea> </div></td> </tr> <tr> <td> </td> <td><label> <div align="center"> <input type="submit" name="update" id="update" value="update" /> </div> </label></td> </tr> <tr> <td> </td> <td> </td> </tr> </table> </form>'; $query = "SELECT * FROM ttnews ORDER BY id ASC"; $result = mysql_query($query) or die(mysql_error()); $ttnews=mysql_fetch_array($result); echo $content; } else{ echo "You Must Be Logged In To Do That"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/110289-solved-update-record/ Share on other sites More sharing options...
emediastudios Posted June 15, 2008 Author Share Posted June 15, 2008 I got it to echo the result!! Quote Link to comment https://forums.phpfreaks.com/topic/110289-solved-update-record/#findComment-565892 Share on other sites More sharing options...
emediastudios Posted June 15, 2008 Author Share Posted June 15, 2008 Im hoppless I know someone here could do this in a second. This is my code, full of errors i know. <?php include_once('includes/include.php'); $ttnews=$_POST['news']; $query = "UPDATE ttnews ,$ttnews"; $result = mysql_query($query) or die(mysql_error()); header("Location: updated.php"); ?> I have 2 fileds in my ttnews table. 1d and news. Quote Link to comment https://forums.phpfreaks.com/topic/110289-solved-update-record/#findComment-565897 Share on other sites More sharing options...
wildteen88 Posted June 15, 2008 Share Posted June 15, 2008 Your query is wrong. A Valid UPDATE query example UPDATE table SET some_field='new_value' WHERE id=1 Quote Link to comment https://forums.phpfreaks.com/topic/110289-solved-update-record/#findComment-565898 Share on other sites More sharing options...
emediastudios Posted June 15, 2008 Author Share Posted June 15, 2008 I changed the code to this but it inserts nothing and erases the text that is in that field. <?php include_once('includes/include.php'); $AA=$_POST['news']; $query = "UPDATE ttnews SET news='$AA' WHERE id=1"; $result = mysql_query($query) or die(mysql_error()); header("Location: updated.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/110289-solved-update-record/#findComment-565899 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.