George Botley Posted March 10, 2009 Share Posted March 10, 2009 ...ld be my data. The editor will allow me to type within the system I have created... And will successfully output the data in variables. However, what it's failing to achieve is the actual INSERT or UPDATE to the database therefore resulting in no CMS changes. It will work only when it is simple formatting such as <p></p> and <h1></h1> etc... however for large amounts of it, such as <img> (like you'd expect from a WYSIWYG editor in a CMS) it just goes wrong. I wonder why this is... Please help, this client is down my neck. The WYSIWYG editor is set as the name tag of content and the scripts call it as $content Could it be anything to do with the database or insert scripts? Here's the code(s): INSERT for new pages <? /* Include Configuration Files */ include_once "../config/config.php"; /* Retrieve META Data From Database */ //Add Page $save = $_GET["save"]; if("yes" == $save) { /* Update Page Information throughout database. */ $title = $_POST["title"]; $content = $_POST["content"]; $year = date('Y'); $month = date('m'); $day = date('d'); $date2 = $year-$month-$date; $visible = $_POST["visible"]; mysql_connect($server, $dbuser, $dbpass) or die ("Could not connect to mysql because ".mysql_error()); mysql_select_db($database) or die ("Could not select database because ".mysql_error()); $query = mysql_query("SELECT * FROM ap_pages WHERE title LIKE '$title'"); $num_rows = mysql_num_rows($query); if(empty($title) || empty($content) || empty($visible)) { echo "<div class='alerterror_info'> <strong>Please Complete All Fields</strong> - $fname, Please complete all of the fields inorder to add this page successfully. </div>"; $title1 = $_POST["title"]; $content1 = $_POST["content"]; } elseif('0' == $num_rows) { mysql_query("INSERT INTO ap_pages (title, content, date, dateedit, visible) VALUES ('$title', '$content', '$year-$month-$day', '$year-$month-$day', '$visible')"); echo "<div class='alertsuccess_info'><strong>Page Added Successfully</strong> - This page has been added successfully. You selected $visible for visibility. Forwarding to page listings in 3 seconds.</div>"; echo '<meta http-equiv="refresh" content="3;url=index.php?ToDo=WebsiteContent/ViewPages" />'; echo "$content"; } else { echo '<meta http-equiv="refresh" content="0;url=index.php?ToDo=WebsiteContent/ViewPages&error=yes1" />'; } } ?> UPDATE for edits <? /* Include Configuration Files */ include_once "../config/config.php"; //Edit Page $edit = $_GET["edit"]; if("yes" == $edit) { /* Update Page within database. */ $year = date('Y'); $month = date('m'); $day = date('d'); $con = mysql_connect("$server","$dbuser","$dbpass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("$database", $con); $id = $_POST["id"]; $title1 = $_POST["title"]; $content = $_POST["content"]; $visible = $_POST["visible"]; mysql_query("UPDATE ap_pages SET title = '$title1' WHERE id LIKE '$id'"); mysql_query("UPDATE ap_pages SET content = '$content' WHERE id LIKE '$id'"); mysql_query("UPDATE ap_pages SET dateedit = '$year-$month-$day' WHERE id LIKE '$id'"); mysql_query("UPDATE ap_pages SET visible = '$visible' WHERE id LIKE '$id'"); mysql_close($con); echo '<div class="alertsuccess_info"> <strong>Page Modified Successfully</strong> - Your changes have taken effect immeadiately. </div>'; echo "<meta http-equiv='refresh' content='3;url=index.php?ToDo=WebsiteContent/ViewPages' />"; } if("yes" != $edit) { $con = mysql_connect("$server","$dbuser","$dbpass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("$database", $con); $pageid = $_GET["id"]; $result = mysql_query("SELECT * FROM ap_pages WHERE id = '$pageid'"); while($row = mysql_fetch_array($result)) { $id = $row['id']; $title1 = $row['title']; $content = $row['content']; $date = $row['date']; $date1 = $row['dateedit']; $visible = $row['visible']; } } ?> What could it be? Within the page creation it will forward to the INSERT script, and output the code as you can see where I have echoed the content variable to see if it actually POST's the data. If there is complex code within the WYSIWYG it never actually INSERTS the page, not even the title. :-\ :'( What could it be guys? Link to comment https://forums.phpfreaks.com/topic/148825-solved-tinymce-wysiwyg-editor-failing-to-enter-data-into-database-or-update-data-cou/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.