[PHP] fckeditor php en mysql

Pagina: 1
Acties:

Onderwerpen


Acties:
  • 0 Henk 'm!

Verwijderd

Topicstarter
ik ben al de hele ochtend bezig met een raar probleem. Ik gebruik een FCK editor om iets p[ te slaan in de database en functioneert als een cms html systeem. Ik heb de volgende code:

PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php  
   
  // Connect to the database 
  $cnx = mysql_connect("localhost", "zegikniet", "zegikookniet") 
         OR die("Unable to connect to database!"); 
  mysql_select_db("mijndatabasenaam", $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: test3.php"); 
  } 

?>

<?php
include_once("fckeditor/fckeditor.php") ;
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
<head> 
<title>Test FCKeditor</title> 
</head> 
<body> 

<form action="test3.php" method="post"> 

<?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('FCKeditor1') ;
$oFCKeditor->BasePath = 'fckeditor/' ;
$oFCKeditor->Value    = $data["data"]; 
$oFCKeditor->Width    = 400; 
$oFCKeditor->Height   = 300;
$oFCKeditor->ToolbarSet = 'Basic'; 
echo $oFCKeditor->CreateHtml();
?>
    
<br>
    
<input type="hidden" name="submit_form" value="1" /> 
<input type="submit" value="Save Form" /> 
</form> 
  
</body>
</html>

<?php  
  // Close the database connection 
  mysql_close($cnx); 
?>


Het probleem is dat hij de data niet opslaat in de database. Als ik manueel iets invoer in de database haalt hij wel netjes de data uit de database, maar zodra ik deze data wijzig en opsla, dan haalt hij de kolom in de database leeg, alleen de id=1 blijft staan.

Acties:
  • 0 Henk 'm!

  • Cartman!
  • Registratie: April 2000
  • Niet online
PHP:
1
2
3
$data = mysql_real_escape_string(trim($_POST['fcktext']));  

$oFCKeditor = new FCKeditor('FCKeditor1') ;


Lijkt me vrij duidelijk ;)

edit: leer debuggen, kijk wat er in $_POST zit en wat voor html FCK daadwerkelijk maakt.

[ Voor 23% gewijzigd door Cartman! op 30-10-2008 11:38 ]