Results 1 to 3 of 3

Thread: cannot get the contents to update

  1. #1
    Join Date
    Feb 2008
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default cannot get the contents to update

    hi
    i can retrieve the data from the db but i cannot amend any ideas?

    Kind Regards
    Iqbal


    <?php # Script 12.3 - cmsadmin.php
    //this is the main page for the site

    //Set the page title and include the html header
    $page_title = 'Admin Side';

    require_once ('./includes/mysql_connect.php');
    include('./includes/header.html');

    if(isset($_GET['content_categories_id']))
    {
    $query = "SELECT content_id, title, summary, contents ".
    "FROM contents ".
    "WHERE content_id = '{$_GET['content_categories_id']}'";
    $result = mysql_query($query) or die('Error : ' . mysql_error());
    list($content_id, $title, $summary, $contents) = mysql_fetch_array($result, MYSQL_NUM);

    $contents = htmlspecialchars($contents);
    }
    else if(isset($_POST['title']))
    {
    $content_id = $_POST['content_categories_id'];
    $title = $_POST['title'];
    $summary = $_POST['summary'];
    $contents = $_POST['contents'];

    if(!get_magic_quotes_gpc())
    {
    $title = addslashes($title);
    $summary = addslashes($summary);
    $contents = addslashes($contents);
    }

    // update the content in the database

    // update the article in the database
    $query = "UPDATE contents ".
    "SET title = '$title', contents = '$contents' ".
    "WHERE content_id = '$content_id'";
    mysql_query($query) or die('Error : ' . mysql_error());

    echo $content_id;

    echo "<p align='center'>Page updated</p>";

    }
    mysql_close();
    ?>
    <form name="edit" action="cms-edit.php" method="post" onsubmit="return submitForm();">

    <input type="hidden" name="id" value="<?=$content_id;?>">

    <script language="JavaScript" type="text/javascript">
    <!--
    function submitForm() {
    //make sure hidden and iframe values are in sync before submitting form
    updateRTE('rte1'); //use this when syncing only 1 rich text editor ("rtel" is name of editor)
    //updateRTEs(); //uncomment and call this line instead if there are multiple rich text editors inside the form
    alert("Submitted value: "+document.myform.rte1.value) //alert submitted value
    return true; //Set to false to disable form submission, for easy debugging.
    }

    //Usage: initRTE(imagesPath, includesPath, cssFile)
    initRTE("images/", "", "");
    //-->
    </script>

    <div id="table">

    <p class="blue">1. Enter the Title</p>

    <table border="0" cellpadding="5" cellspacing="0" width="100%">
    <tbody>
    <tr>
    <td bgcolor="#f7eedc">&nbsp;Title</td>
    </tr>
    <tr>
    <td bgcolor="#f7eedc" width="100%"><input type="text" name="title" size="40" maxlength="60" id="title" value="<?php echo $title; ?>"/></td>
    </tr>
    </tbody>
    </table>
    <br />

    <p class="blue">2. Enter the Summary</p>
    <p class="advice">A short summary of the content</p>

    <table border="0" cellpadding="5" cellspacing="0" width="100%">
    <tbody>
    <tr>
    <td bgcolor="#f7eedc">&nbsp;Summary</td>
    </tr>
    <tr>
    <td bgcolor="#f7eedc" width="100%">
    <textarea name="summary" cols="40" rows="5" class="box" id="summary"><?=$summary;?></textarea></td>
    </tr>
    </tbody>
    </table>
    <br />

    <p class="blue">3. Enter the Content</p>
    <script language="JavaScript" type="text/javascript">

    </script>
    <table border="0" cellpadding="5" cellspacing="0" width="100%">
    <tbody>
    <tr>
    <td bgcolor="#f7eedc">&nbsp;Content</td>
    </tr>
    <tr>
    <td bgcolor="#f7eedc" width="100%"><script language="JavaScript" type="text/javascript">
    <!--
    function submitForm() {
    //make sure hidden and iframe values are in sync before submitting form
    //to sync only 1 rte, use updateRTE(rte)
    //to sync all rtes, use updateRTEs
    //updateRTE('rte1');
    updateRTEs();
    alert("rte1 = " + document.txteditor.rte1.value);


    //change the following line to true to submit form
    return false;
    }

    //Usage: initRTE(imagesPath, includesPath, cssFile)
    initRTE("themes/default/images/", "", "");
    //-->
    </script>
    <noscript><p><b>Javascript must be enabled to use this form.</b></p></noscript>

    <script language="JavaScript" type="text/javascript">

    //Usage: writeRichText(fieldname, html, width, height, buttons, readOnly)
    writeRichText('contents', '<?=$contents;?>', 520, 200, true, false);
    //-->

    </script></td>
    </tr>
    </tbody>
    </table>
    <br />

    <div id="submitted"><input type="submit" name="save" id="save" value="Save Page" /></div>

    </div>

    </form>

    <div id="bgbottom"><img src="themes/default/images/bgbottom.gif" width="785" height="75" alt="bottompanel"></div>

    </div>

    </body>

    </html>

  2. #2
    Join Date
    Feb 2008
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks for the help, i have resloveed the problem

  3. #3
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    please use [code][/code] tags when posting computer code

    and congrats of finding the error

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •