tecmeister Posted April 4, 2009 Share Posted April 4, 2009 Hi everyone, I'm trying to update the date from my form but I seem to be getting a error 'parse error' this is the script that I have used: <?php } if(isset($_GET['update'])) { $id = $_GET['update']; $query = "SELECT * FROM news WHERE ID=$id LIMIT 1"; $result = mysql_query($query); $r = mysql_fetch_assoc($result); ?> <form action="<?php $_SERVER['PHP_SELF']?>?update_complete=" method="post"> <table align="center" border=" 1px #ccc solid" cellspacing="0" cellpadding="2" style=" margin-top: 10px"> <tr> <td>Header:</td> <td><input type="text" name="header" value="<?php echo $r['header'] ?>" style=" width: 300px" /></td> <input type="hidden" name="id" value="<?php echo $id ?>" /> </tr> <tr> <td>News:</td> <td><textarea cols="60" rows="10" name="news"><?php echo $r['news'] ?></textarea></td> </tr> <tr> <td>Date:</td> <td><input type="text" name="date" value="<?php echo $r['date'] ?>" /></td> </tr> <tr> <td></td> <td><input type="submit" value="Add News" name="update_news" /></td> </tr> </table> </form> <?php } ?> <?php if(isset($_POST['update_news'])) { $id = $_POST['id']; $header = $_POST['header']; $news = $_POST['news']; $date = $_POST['date'] mysql_query("UPDATE news SET header='$header', news='$news', date='$date' WHERE ID=$id"); } ?> Thanks for you help, tecmeister. Quote Link to comment https://forums.phpfreaks.com/topic/152487-solved-mysql-update-form/ Share on other sites More sharing options...
Maq Posted April 4, 2009 Share Posted April 4, 2009 Missing a ';' $date = $_POST['date']; Quote Link to comment https://forums.phpfreaks.com/topic/152487-solved-mysql-update-form/#findComment-800831 Share on other sites More sharing options...
tecmeister Posted April 4, 2009 Author Share Posted April 4, 2009 LOL. I'm a complete nooob. Thanks alot Quote Link to comment https://forums.phpfreaks.com/topic/152487-solved-mysql-update-form/#findComment-800832 Share on other sites More sharing options...
Maq Posted April 4, 2009 Share Posted April 4, 2009 LOL. I'm a complete nooob. Thanks alot Lol, you're welcome. The errors should have told you what line it was on. Actually it probably pointed to the last line. Anyway, mark as [sOLVED] please, thx Quote Link to comment https://forums.phpfreaks.com/topic/152487-solved-mysql-update-form/#findComment-800834 Share on other sites More sharing options...
tecmeister Posted April 4, 2009 Author Share Posted April 4, 2009 I have got another question. Now when I try to update the form it is limiting to the amout of characters I can update it to how do I change this? The typr is under text and I have tried long text but stil the same Quote Link to comment https://forums.phpfreaks.com/topic/152487-solved-mysql-update-form/#findComment-800839 Share on other sites More sharing options...
Maq Posted April 4, 2009 Share Posted April 4, 2009 What's the exact error? And put this after you query in case it contains errors. This will kill the script and output a "descriptive" error message. mysql_query("UPDATE news SET header='$header', news='$news', date='$date' WHERE ID=$id") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/152487-solved-mysql-update-form/#findComment-800845 Share on other sites More sharing options...
tecmeister Posted April 4, 2009 Author Share Posted April 4, 2009 I have figured it out. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/152487-solved-mysql-update-form/#findComment-800849 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.