php - update sql statement not working -


i new programming. try update sql not working. result show success alert come out info not updated.

this html code. using tinymce

<?php   include("db.php");   dodb();    $id = $_get['id'];    $get_contents_sql = "select * service service_id='$id'";   $get_contents_res = mysqli_query($mysqli, $get_contents_sql)   or die(mysqli_error($mysqli));    if($get_contents_res = mysqli_query($mysqli, $get_contents_sql)){     //fetch associative array     while ($row = mysqli_fetch_assoc($get_contents_res)) {          $contents = $row['contents'];       $service_name = $row['service_name'];       $service_id = $row['service_id'];        //draw results       $fill_block = html_entity_decode($contents);     }   }    //close connection mysql   mysqli_close($mysqli); ?> <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>full featured example</title> <meta http-equiv="x-ua-compatible" content="ie=edge" /> <!-- tinymce --> <script type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js">     </script> <script type="text/javascript">     tinymce.init({         // general options         mode : "textareas",         theme : "advanced",         plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave,visualblocks",          // theme options         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,restoredraft,visualblocks",         theme_advanced_toolbar_location : "top",         theme_advanced_toolbar_align : "left",         theme_advanced_statusbar_location : "bottom",         theme_advanced_resizing : true,          // example content css (should site css)         content_css : "examples/css/content.css",          // drop lists link/image/media/template dialogs         template_external_list_url : "examples/lists/template_list.js",         external_link_list_url : "examples/lists/link_list.js",         external_image_list_url : "examples/lists/image_list.js",         media_external_list_url : "examples/lists/media_list.js",          // style formats         style_formats : [             {title : 'bold text', inline : 'b'},             {title : 'red text', inline : 'span', styles : {color : '#ff0000'}},             {title : 'red header', block : 'h1', styles : {color : '#ff0000'}},             {title : 'example 1', inline : 'span', classes : 'example1'},             {title : 'example 2', inline : 'span', classes : 'example2'},             {title : 'table styles'},             {title : 'table row 1', selector : 'tr', classes : 'tablerow1'}         ],          // replace values template plugin         template_replace_values : {             username : "some user",             staffid : "991234"         }     }); </script> <!-- /tinymce -->  </head> <body role="application">  <form method="post" action="updateserviceexe.php">  <p>service name:   <input name="txtservicename" type="text" value="<?php echo $service_name; ?>" />    <!-- gets replaced tinymce, remember html in textarea should      encoded -->   <input type="hidden" name="hidid" value="<? echo $row['service_id'];?>" />  </p>     <div>          <!-- gets replaced tinymce, remember html in textarea should      encoded --> <div>   <textarea id="elm1" name="elm1" rows="15" cols="80" style="width:80%">     <?php echo $fill_block; ?>   </textarea> </div>          <!-- integration calls -->         <a href="javascript:;" onclick="tinymce.get('elm1').show();return false;">[show]</a>         <a href="javascript:;" onclick="tinymce.get('elm1').hide();return false;">[hide]</a>         <a href="javascript:;" onclick="tinymce.get('elm1').execcommand('bold');return false;">[bold]</a>         <a href="javascript:;" onclick="alert(tinymce.get('elm1').getcontent());return false;">[get contents]</a>         <a href="javascript:;" onclick="alert(tinymce.get('elm1').selection.getcontent());return false;">[get selected html]</a>         <a href="javascript:;" onclick="alert(tinymce.get('elm1').selection.getcontent({format : 'text'}));return false;">[get selected text]</a>         <a href="javascript:;" onclick="alert(tinymce.get('elm1').selection.getnode().nodename);return false;">[get selected element]</a>         <a href="javascript:;" onclick="tinymce.execcommand('mceinsertcontent',false,'<b>hello world!!</b>');return false;">[insert html]</a>         <a href="javascript:;" onclick="tinymce.execcommand('mcereplacecontent',false,'<b>{$selection}</b>');return false;">[replace selection]</a>          <br />         <input type="submit" name="save" value="submit" />         <input type="reset" name="reset" value="reset" />     </div> </form> <br> <script type="text/javascript"> if (document.location.protocol == 'file:') {     alert("the examples might not work on local file system due security settings in browser. please use real webserver."); } </script> </body> </html> 

this php code

<?php //session_start(); include('../conn/openconn.php'); if(isset($_post['save'])) {      $id = $_post['hidid'];      $servicename = $_post['txtservicename'];     $contents = $_post['elm1'];      $updateuser = "update service set                     service_name = '$servicename',                    contents = '$contents'                    service_id = '$id'";         mysql_query($updateuser) or die (mysql_error());           header("location:viewserviceupdate.php?alert=success"); }  ?> 

change update statement below -

"update service set                 service_name = $servicename,                contents = $contents                service_id = $id" 

here have removed single quote surrounding variables.

note:

please stop using mysql_query(). extension deprecated of php 5.5.0, , removed in future. instead, mysqli or pdo_mysql extension should used.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

qt - How to embed QML toolbar and menubar into QMainWindow -