Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jan 2010
    Posts
    153
    Thanks
    53
    Thanked 0 Times in 0 Posts

    Updating mysql with php!! Help!!

    Hello. I'm new to php/mysql. But I wanted to make a page where I can update a table in mysql. The page where I would do that is /addpage.php. I'm using an editor to get the content in HTML and then put it into a table in mysql

    addpage.php
    PHP Code:
    <html><head><script language="javascript" type="text/javascript" src="tiny_mce/tiny_mce.js"></script>
    <script language="javascript" type="text/javascript">
    tinyMCE.init({
        mode : "textareas",
        theme : "advanced",
        plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
        theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
        theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
        theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
        theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : true,
        extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
        template_external_list_url : "example_template_list.js"
    });

    </script>
    </head>
    <?php
        
    include ('config.php');
      if (
    $_GET[done] == 1) {

    mysql_connect("$server""$username""$password") or die ($theError);
    mysql_select_db("$database") or die ($theError);

    mysql_query("INSERT INTO pages 
    (pagez) 
    VALUES
    ('$_POST[content]')"
    );

      } else {
    ?>
    <body>
    <form id="form1" name="form1" method="post" action="?done=1">
      <label>
      <div align="center"><span class="style1">Page name <br />

      </span></div>
      </label>
      <p align="center" class="style1">
        <label>Page content <b>(HTML)</b><br />
        <textarea name="content" cols="75" rows="4"></textarea>
        </label>
      </p>
      <p align="center" class="style1">
        <label></label>
      </p>
      <p align="center">
        <label>
        <input type="submit" name="Submit" value="Submit" />
        </label>
        <label>
        <input type="reset" name="Submit2" value="Reset" />
        </label>
      </p>
    </form>
    <?   }
      
    ?>
    </body>
    </html>
    So when I go check the table in mysql, it's not updated.

    Please help

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    PHP Code:
    mysql_query("INSERT INTO pages 
    (pagez) 
    VALUES
    ('$_POST[content]')"
    ) or die(mysql_error()); 
    Is it whining about a duplicate key for entry ''?
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

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