title: CKeditor And php echo
body: <p>I am trying to add CKeditor to this script. It works fine when I add openwysiwyg to it. but i just cant seem to get ckeditor to work. I added this to the head</p>
  
  <pre><code> &lt;head&gt;&lt;script src="/ckeditor/ckeditor.js"&gt;&lt;/script&gt; &lt;/head&gt; 
  and this to ---&gt; echo "  &lt;script&gt;CKEDITOR.replace( \'HtmlEditor3\' );&lt;/script&gt;
  </code></pre>
  
  <p>the body. i get this  <code>Parse error: syntax error, unexpected on line 285</code></p>
  
  <pre><code>&lt;?php
  
     // *************************************** //
  
     //                CHIP                    //
  
     //                                        //
  
     // *************************************** //
  
  
  
     define('ADMIN_PASS', 'password');
  
     $upload_folder = "./images/";
  
     $max_size = 200000;
  
     $database = './news_db.php';
  
     $admin_password = isset($_COOKIE['admin_password']) ? $_COOKIE['admin_password'] : '';
  
  
  
     if (empty($admin_password))
  
     {
  
        if (isset($_POST['admin_password']))
  
        {
  
           $admin_password = md5($_POST['admin_password']);
  
            if ($admin_password == md5(ADMIN_PASS))
  
            {
  
               setcookie('admin_password', $admin_password);
  
            }
  
        }
  
     }
  
  
  
     (is_writable($database)) ? include($database): die ($database . ' is not writable or does not exist! Please read the manual for more details.');
  
     $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
  
     $index = isset($_REQUEST['index']) ? $_REQUEST['index'] : -1;
  
     $is_admin = ($admin_password == md5(ADMIN_PASS));
  
     $is_modified = false;
  
     $count = sizeof($news);
  
     if ($action == 'logout')
  
     {
  
        setcookie('admin_password', '');
  
        unset($_COOKIE['admin_password'], $admin_password);
  
        header("Location: ".basename(__FILE__));
  
        exit;
  
     }
  
     else
  
     if ($action == 'save')
  
     {
  
        $text = get_magic_quotes_gpc() ? trim($_POST['text']) : addslashes(trim($_POST['text']));
  
        $text = str_replace("\\'", "&amp;#39;", $text);
  
        if ($index &gt;= 0 &amp;&amp; $index &lt; $count)
  
        {
  
           $news[$index] = $text;
  
        }
  
        else
  
        {
  
           $news[$count] = $text;
  
           $count++;
  
        }
  
        $is_modified = true;
  
     }
  
     else
  
     if ($action == 'movedown')
  
     {
  
        if ($index &gt; 0 &amp;&amp; $index &lt; $count)
  
        {
  
           $temp = $news[$index-1];
  
           $news[$index-1] = $news[$index];
  
           $news[$index] = $temp;
  
           $is_modified = true;
  
        }
  
        else
  
        {
  
           header('Location: '.basename(__FILE__));
  
           exit;
  
        }
  
     }
  
     else
  
     if ($action == 'moveup')
  
     {
  
        if ($index &gt;= 0 &amp;&amp; $index &lt; ($count-1))
  
        {
  
           $temp = $news[$index+1];
  
           $news[$index+1] = $news[$index];
  
           $news[$index] = $temp;
  
           $is_modified = true;
  
        }
  
        else
  
        {
  
           header('Location: '.basename(__FILE__));
  
           exit;
  
        }
  
     }
  
     else
  
     if ($action == 'delete')
  
     {
  
        $count--;
  
        for ($i=$index; $i &lt; $count; $i++)
  
        {
  
           $news[$i] = $news[$i+1];
  
        }
  
        $is_modified = true;
  
     }
  
     if ($is_modified &amp;&amp; $is_admin)
  
     {
  
        $content = "&lt;?php\r\n";
  
        for ($i=0; $i &lt; $count; $i++)
  
        {
  
           $content .= '$news['.$i.'] = '."'".$news[$i]."';\r\n";
  
        }
  
        $content .= "?&gt;";
  
        $content = str_replace('\"', '"', $content);
  
        $file = fopen($database, "wb");
  
        fputs($file, $content);
  
        fclose($file);
  
        header('Location: '.basename(__FILE__));
  
        exit;
  
     }
  
  ?&gt;
  
  &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;
  
  &lt;html&gt;
  
  &lt;head&gt;
  &lt;script src="/ckeditor/ckeditor.js"&gt;&lt;/script&gt;
  
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  
  &lt;title&gt;News Writer&lt;/title&gt;
  
  &lt;style type="text/css"&gt;
  
  &lt;!--
  
  body
  
  {
  
     font-size: 11px;
  
     font-family: Verdana;
  
     font-weight: normal;
  
     text-decoration: none;
  
     color: #212121;
  
  }
  
  --&gt;
  
  &lt;/style&gt;
  
  &lt;/head&gt;
  
  &lt;body bgcolor="#F7F6F3" style="margin:0px 0px 0px 0px"&gt;
  
  &lt;?php
  
  
  
     if ($action == 'admin')
  
     {
  
        echo "&lt;center&gt;\n";
  
        echo "Administrator login&lt;br&gt;\n";
  
        echo "&lt;form method=\"post\" action=\"" .basename(__FILE__) . "\"&gt;\n";
  
        echo "&lt;input type=\"password\" name=\"admin_password\" size=\"20\" /&gt;\n";
  
        echo "&lt;input type=\"submit\" value=\"Login\" name=\"submit\" /&gt;\n";
  
        echo "&lt;/form&gt;\n";
  
        echo "&lt;/center&gt;\n";
  
     }
  
     else
  
     if ($action == 'image')
  
     {
  
        if ($is_admin)
  
        {
  
           echo "&lt;center&gt;\n";
  
           echo "Upload image&lt;br&gt;\n";
  
           echo "&lt;form enctype=\"multipart/form-data\" method=\"post\" action=\"" .basename(__FILE__) . "\"&gt;\n";
  
           echo "&lt;input type=\"hidden\" name=\"action\" value=\"upload\" /&gt;\n";
  
           echo "Image filename: &lt;input type=\"file\" name=\"filename\"&gt;&lt;br&gt;\n";
  
           echo "&lt;input type=\"submit\" value=\"Upload\"&gt;\n";
  
           echo "&lt;/form&gt;\n";
  
           echo "&lt;a href=\"" .basename(__FILE__). "\"&gt;Back to overview&lt;/a&gt;\n";
  
           echo "&lt;/center&gt;\n";
  
        }
  
     }
  
     else
  
     if ($action == 'imagelist')
  
     {
  
        if ($is_admin)
  
        {
  
           $ext_to_show = array("gif","jpg","jpeg","jpe","pjpeg");
  
           $files_to_show = array();
  
           if ($handle = opendir($upload_folder))
  
           {
  
              while (false !== ($file = readdir($handle)))
  
              {
  
                 if ($file != "." &amp;&amp; $file != ".." &amp;&amp; is_file($upload_folder.$file))
  
                 {
  
                    $ext = (pathinfo($upload_folder.$file));
  
                    if(in_array(strtolower($ext['extension']), $ext_to_show))
  
                    {
  
                       $files_to_show[] = $file;
  
                    }
  
                 }
  
              }
  
              closedir($handle);
  
           }
  
           if(empty($files_to_show))
  
           {
  
              echo "No files to show.";
  
           }
  
           else
  
           {
  
              sort($files_to_show);
  
              foreach ($files_to_show as $file)
  
              {
  
                 echo '&lt;br&gt;&lt;img src="'.$upload_folder.$file.'"alt="" align="middle" border="0" style="width:120px;height:90px;"&gt;'."\n";
  
                 echo '&lt;input type="text" size="30" value="'.$upload_folder.$file.'"&gt;&lt;br&gt;'."\n";
  
              }
  
           }
  
           echo "&lt;/body&gt;&lt;/html&gt;";
  
           exit;
  
        }
  
     }
  
     else
  
     if ($action == 'upload')
  
     {
  
        echo "&lt;center&gt;\n";
  
        if (isset($_FILES['filename']))
  
        {
  
           $name  = $_FILES['filename']['name'];
  
           $type  = $_FILES['filename']['type'];
  
           $tmp_name = $_FILES['filename']['tmp_name'];
  
           $error = $_FILES['filename']['error'];
  
           $size  = $_FILES['filename']['size'];
  
           switch ($error)
  
           {
  
           case 0:
  
              if ($type == 'image/gif' || $type == 'image/jpeg' || $type == 'image/pjpeg')
  
              {
  
                 if ($size &lt;= $max_size)
  
                 {
  
                    if (!file_exists($upload_folder. $name))
  
                    {
  
                       if (move_uploaded_file($tmp_name, $upload_folder. $name))
  
                       {
  
                          echo "Image succesfully uploaded!&lt;br&gt;&lt;br&gt;\n";
  
                          echo "Filename:&lt;br&gt;". $upload_folder. $name. "&lt;br&gt;\n";
  
                       }
  
                       else
  
                       {
  
                          echo "Error: Upload failed, please verify the folder's permissions.\n";
  
                       }
  
                    }
  
                    else
  
                    {
  
                       echo "Error: The image already exists.\n";
  
                    }
  
                 }
  
                 else
  
                 {
  
                    echo "Error: The image is too big.\n";
  
                 }
  
              }
  
              else
  
              {
  
                 echo "Error: Wrong file type, please only use jpg or gif images.\n";
  
              }
  
              break;
  
           case 1:
  
              echo "Error: The uploaded file exceeds the 'upload_max_filesize' directive.\n";
  
              break;
  
           case 2:
  
              echo "Error: The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.\n";
  
              break;
  
           case 3:
  
              echo "Error: The uploaded file was only partially uploaded.\n";
  
              break;
  
           case 4:
  
              echo "Error: No file was uploaded.\n";
  
              break;
  
           case 6:
  
              echo "Error: Missing a temporary folder.\n";
  
              break;
  
           case 7:
  
              echo "Error: Failed to write file to disk.\n";
  
              break;
  
           case 8:
  
              echo "Error: File upload stopped by extension.\n";
  
              break;
  
           }
  
        }
  
        else
  
        {
  
           echo "Error: No filename specified!&lt;br&gt;\n";
  
        }
  
        echo "&lt;a href=\"" .basename(__FILE__). "\"&gt;&lt;br&gt;&lt;br&gt;Back to overview&lt;/a&gt;\n";
  
        echo "&lt;/center&gt;\n";
  
        exit;
  
     }
  
     else
  
     if ($action == 'edit' || $action == 'new')
  
     {
  
        if ($is_admin)
  
        {
  
           $text = ($index &gt;= 0) ? $news[$index] : '';
  
           echo "&lt;form action=\"" .basename(__FILE__) . "\" method=\"POST\"&gt;\n";
  
           echo "&lt;table width=\"100%\" cellpadding=\"0\" cellspacing=\"4\" border=\"0\"&gt;\n";
  
           echo "&lt;tr&gt;\n";
  
           echo "&lt;td&gt;\n";
  
           echo "   &lt;textarea id=\"HtmlEditor3\" style=\"width:100%;height:250\" name=\"text\"&gt;".$text."&lt;/textarea&gt;\n";
           echo "  &lt;script&gt;CKEDITOR.replace( \'HtmlEditor3\' );&lt;/script&gt;
  
           echo "&lt;/td&gt;\n";
  
           echo "&lt;/tr&gt;\n";
  
           echo "&lt;tr&gt;\n";
  
           echo "&lt;td align=left&gt;\n";
  
           echo "   &lt;input type=\"hidden\" name=\"action\" value=\"save\" /&gt;\n";
  
           echo "   &lt;input type=\"hidden\" name=\"index\" value=\"" . $index . "\" /&gt;\n";
  
           echo "   &lt;input type=\"submit\" value=\"Save\" /&gt;\n";
  
           echo "   &lt;input type=\"button\" value=\"Back to overview\" onclick=\"window.location='" .basename(__FILE__) . "'\" /&gt;\n";
  
           echo "&lt;/td&gt;\n";
  
           echo "&lt;/tr&gt;\n";
  
           echo "&lt;/table&gt;\n";
  
           echo "&lt;/form&gt;\n";
  
        }
  
     }
  
     else
  
     {
  
        if ($is_admin)
  
        {
  
           echo "&lt;a href=\"".basename(__FILE__)."?action=new\"&gt;Create new item&lt;/a&gt;&amp;nbsp;&amp;nbsp;";
  
           echo "&lt;a href=\"".basename(__FILE__)."?action=image\"&gt;Upload image&lt;/a&gt;&amp;nbsp;&amp;nbsp;";
  
           echo "&lt;a href=\"".basename(__FILE__)."?action=imagelist\" onClick=\"window.open('','img_list','scrollbars=yes, resizable=yes, width=400, height=300')\" target=\"img_list\"&gt;Image List&lt;/a&gt;&amp;nbsp;&amp;nbsp;";
  
           echo "&lt;a href=\"".basename(__FILE__)."?action=logout\"&gt;Logout&lt;/a&gt;&lt;br&gt;&lt;br&gt;\n";
  
        }
  
        if ($count &gt; 0)
  
        {
  
           for ($i=$count-1; $i &gt;= 0; $i--)
  
           {
  
              echo $news[$i];
  
              echo "&lt;br&gt;";
  
              echo "&lt;br&gt;\n";
  
              if ($is_admin)
  
              {
  
                 echo "&lt;table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"&gt;\n";
  
                 echo "&lt;tr&gt;\n";
  
                 echo "&lt;td&gt;\n";
  
                 echo "   &lt;table cellpadding=\"0\" cellspacing=\"4\" border=\"0\"&gt;\n";
  
                 echo "   &lt;tr&gt;\n";
  
                 echo "   &lt;td&gt;\n";
  
                 echo "      &lt;form action=\"" .basename(__FILE__) . "\"&gt;\n";
  
                 echo "      &lt;input type=\"hidden\" name=\"action\" value=\"edit\" /&gt;\n";
  
                 echo "      &lt;input type=\"hidden\" name=\"index\" value=\"" . $i . "\" /&gt;\n";
  
                 echo "      &lt;input type=\"submit\" value=\"Edit\" /&gt;\n";
  
                 echo "      &lt;/form&gt;\n";
  
                 echo "   &lt;/td&gt;\n";
  
                 echo "   &lt;td&gt;\n";
  
                 echo "      &lt;form action=\"" .basename(__FILE__) . "\" onSubmit=\"return confirm('Delete item?')\"&gt;\n";
  
                 echo "      &lt;input type=\"hidden\" name=\"action\" value=\"delete\" /&gt;\n";
  
                 echo "      &lt;input type=\"hidden\" name=\"index\" value=\"" . $i . "\" /&gt;\n";
  
                 echo "      &lt;input type=\"submit\" value=\"Delete\" /&gt;\n";
  
                 echo "      &lt;/form&gt;\n";
  
                 echo "   &lt;/td&gt;\n";
  
                 echo "   &lt;/tr&gt;\n";
  
                 echo "   &lt;/table&gt;\n";
  
                 echo "&lt;/td&gt;\n";
  
                 echo "&lt;td&gt;\n";
  
                 echo "   &lt;table align=\"right\" cellpadding=\"0\" cellspacing=\"4\" border=\"0\"&gt;\n";
  
                 echo "   &lt;tr&gt;\n";
  
                 echo "   &lt;td&gt;\n";
  
                 echo "      &lt;form action=\"" .basename(__FILE__) . "\"&gt;\n";
  
                 echo "      &lt;input type=\"hidden\" name=\"action\" value=\"moveup\" /&gt;\n";
  
                 echo "      &lt;input type=\"hidden\" name=\"index\" value=\"" . $i . "\" /&gt;\n";
  
                 echo "      &lt;input type=\"submit\" value=\"Move Up\" /&gt;\n";
  
                 echo "      &lt;/form&gt;\n";
  
                 echo "   &lt;/td&gt;\n";
  
                 echo "   &lt;td&gt;\n";
  
                 echo "      &lt;form action=\"" .basename(__FILE__) . "\"&gt;\n";
  
                 echo "      &lt;input type=\"hidden\" name=\"action\" value=\"movedown\" /&gt;\n";
  
                 echo "      &lt;input type=\"hidden\" name=\"index\" value=\"" . $i . "\" /&gt;\n";
  
                 echo "      &lt;input type=\"submit\" value=\"Move Down\" /&gt;\n";
  
                 echo "      &lt;/form&gt;\n";
  
                 echo "   &lt;/td&gt;\n";
  
                 echo "   &lt;/tr&gt;\n";
  
                 echo "   &lt;/table&gt;\n";
  
                 echo "&lt;/td&gt;\n";
  
                 echo "&lt;/tr&gt;\n";
  
                 echo "&lt;/table&gt;\n";
  
              }
  
              echo "&lt;hr&gt;\n";
  
           }
  
        }
  
        else
  
        {
  
           echo "No news&lt;br&gt;&lt;br&gt;";
  
        }
  
        if (!$is_admin)
  
        {
  
           echo "&lt;a href=\"".basename(__FILE__)."?action=admin\"&gt;Admin login&lt;/a&gt;";
  
        }
  
     }
  
  ?&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>