Raf1k1 Posted February 24, 2010 Share Posted February 24, 2010 Hi, I'm having trouble using TinyMCE to update some content in my database. It's taking me to update.php and displaying a blank page. I thought maybe it's not connecting to the database so I tried using connection script in the update.php file instead of requiring it from another file but it made no difference. Here's the code from the editAbout file: <?php if(isset($_GET['message'])){ echo "<p><font color='red'>Update Successful!</font></p>"; } // Pull About page content from database $sql = "SELECT about_id, about_content FROM about"; $result = $conn->query($sql) or die(mysqli_error()); if($result){ $row = $result->fetch_object(); echo '<form method="post" action="update.php">'; echo '<input type="hidden" name="id" value="'.$row->about_id.'" />'; echo '<textarea name="about_content" cols="80" rows="20">'; echo $row->about_content; echo '</textarea>'; echo '<input type="submit" name="content" value="Update Content" />'; echo '</form>'; } ?> and here's the update.php code: // If user pressed "Update Content" button if(isset($_POST['editContent'])){ // Update page content require("./connection.php"); $about_content = $_POST['content']; $about_id = $_POST['id']; $sql = "UPDATE about SET about_content='$about_content' WHERE about_id='$about_id'"; $result = $conn->query($sql) or die(mysql_error()); if($result){ header("location: adminAbout.php?message=1"); } } Can anyone see where I went wrong? Link to comment https://forums.phpfreaks.com/topic/193265-update-database-content-with-tinymce/ Share on other sites More sharing options...
jl5501 Posted February 24, 2010 Share Posted February 24, 2010 yes this line $about_content = $_POST['content']; should be $about_content = $_POST['about_content']; Link to comment https://forums.phpfreaks.com/topic/193265-update-database-content-with-tinymce/#findComment-1017624 Share on other sites More sharing options...
Raf1k1 Posted February 24, 2010 Author Share Posted February 24, 2010 hmm, didn't work edit: gave me a blank page again Link to comment https://forums.phpfreaks.com/topic/193265-update-database-content-with-tinymce/#findComment-1017629 Share on other sites More sharing options...
jl5501 Posted February 24, 2010 Share Posted February 24, 2010 if you are getting a blank page, there is another error in there somwhere Put this at the beginning of your script error_reporting(E_ALL); ini_set('display_errors',1); Link to comment https://forums.phpfreaks.com/topic/193265-update-database-content-with-tinymce/#findComment-1017636 Share on other sites More sharing options...
teamatomic Posted February 24, 2010 Share Posted February 24, 2010 tinyMCE is for inline editing of pages on your site. Why are you using it to try to manage DB data? For that you make a page that grabs the existing data and then you either edit it or remove it then process it into the DB again. Use the pages you have(editabout.php and update.php) without invloving tinyMCE and you should be able to do what you are trying. HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/193265-update-database-content-with-tinymce/#findComment-1017639 Share on other sites More sharing options...
jl5501 Posted February 24, 2010 Share Posted February 24, 2010 I dont think tinyMCE is the issue here. He is just using it to edit a text area. Link to comment https://forums.phpfreaks.com/topic/193265-update-database-content-with-tinymce/#findComment-1017645 Share on other sites More sharing options...
Raf1k1 Posted February 24, 2010 Author Share Posted February 24, 2010 i changed the following echo '<input type="submit" name="content" to echo '<input type="submit" name="editContent" which didn't seem to do anything but after adding your error reporting code it's seems to be working now which is odd. @above: I'm pretty new to PHP and was wanting to see what I could do with it. I'm guessing you're right as I don't really know much about it and will try doing it the way you've suggested in future. edit: thanks jl5501. It's working the way it should now. Much appreciated I realise that I probably shouldn't be storing the entire contents of a page in one field but I was wanting to start simple and build up to something more complicated later on. Thanks once again. Link to comment https://forums.phpfreaks.com/topic/193265-update-database-content-with-tinymce/#findComment-1017648 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.