Nieuw lid |
|
ik heb een WYSIWYG-editor aan een database gekoppeld, alleen werkt het opslaan in de database niet, hier de code:
<?php
//This section should deal with the MagicQuotes and slashes
function nukeMagicQuotes() {
if (get_magic_quotes_gpc()) {
function stripslashes_deep($value) {
$value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
return $value;
}
$_POST = array_map('stripslashes_deep', $_POST);
$_GET = array_map('stripslashes_deep', $_GET);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
}
}
?>
<?php nukeMagicQuotes(); ?>
<?php
// Connect to the database
$cnx = mysql_connect("localhost", "********", "wachtwoord")
OR die("Unable to connect to database!");
mysql_select_db("**************", $cnx);
if ($_POST['submit_form'] == 1) {
// Save to the database.
$data = mysql_real_escape_string(trim($_POST['fcktext']));
$res = mysql_query("UPDATE fck_data SET data = '".$data."' WHERE id = 1");
if (!$res)
die("Error saving the record! Mysql said: ".mysql_error());
// Redirect to self to get rid of the POST
header("Location: index.php");
}
include_once "../FCKeditor/fckeditor.php";
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Test FCKeditor</title>
<LINK REL="stylesheet" HREF="stijl.css" TYPE="text/css">
<style type="text/css">
.style1 {
text-align: center;
}
</style>
</head>
<body>
<div id="container"><div id="header"><br />
<br />
</div><div id="inhoud"><h2 class="style1">Home tekst bewerken</h2>
<form action="index.php" method="post">
<div class="style1">
<?php
// Get data from the database
$query = mysql_query("SELECT data FROM fck_data WHERE id = 1");
$data = mysql_fetch_array($query);
// Configure and output editor
$oFCKeditor = new FCKeditor('fcktext');
$oFCKeditor->BasePath = "../FCKeditor/";
$oFCKeditor->Value = $data["data"];
$oFCKeditor->Width = 800;
$oFCKeditor->Height = 400;
echo $oFCKeditor->CreateHtml();
?>
<br />
<input type="hidden" name="submit_form" value="1" />
<input type="submit" value="Opslaan" />
</div>
</form>
</div><div id="footer"></div></div>
</body>
</html>
<?php
// Close the database connection
mysql_close($cnx);
?>
<?php //This section should deal with the MagicQuotes and slashes function nukeMagicQuotes() { function stripslashes_deep($value) { return $value; } $_POST = array_map('stripslashes_deep', $_POST); $_GET = array_map('stripslashes_deep', $_GET); $_COOKIE = array_map('stripslashes_deep', $_COOKIE); } } ?> <?php nukeMagicQuotes(); ?> <?php // Connect to the database OR die("Unable to connect to database!"); if ($_POST['submit_form'] == 1) { // Save to the database. $res = mysql_query("UPDATE fck_data SET data = '".$data."' WHERE id = 1"); if (!$res) // Redirect to self to get rid of the POST header("Location: index.php"); } include_once "../FCKeditor/fckeditor.php"; ?> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Test FCKeditor</title> <LINK REL="stylesheet" HREF="stijl.css" TYPE="text/css"> <style type="text/css"> .style1 { text-align: center; } </style> </head> <body> <div id="container"><div id="header"><br /> <br /> </div><div id="inhoud"><h2 class="style1">Home tekst bewerken</h2> <form action="index.php" method="post"> <div class="style1"> <?php // Get data from the database $query = mysql_query("SELECT data FROM fck_data WHERE id = 1"); // Configure and output editor $oFCKeditor = new FCKeditor('fcktext'); $oFCKeditor->BasePath = "../FCKeditor/"; $oFCKeditor->Value = $data["data"]; $oFCKeditor->Width = 800; $oFCKeditor->Height = 400; echo $oFCKeditor->CreateHtml(); ?> <br /> <input type="hidden" name="submit_form" value="1" /> <input type="submit" value="Opslaan" /> </div> </form> </div><div id="footer"></div></div> </body> </html> <?php // Close the database connection ?>
Weet iemand wat er fout is?
|