jquery - While inserting Data into MySQL using Ajax and PHP, taking limited data? -


while inserting data mysql using ajax , php, taking limited data rich textarea,is there problem?

jquery script

   $('#adddesc').click(function(e)     {         e.preventdefault();      var txtcategoryname=tinymce.get('txtcategoryname').getcontent();     var txttitle=$('#txttitle').val();     var selecterror1=$("#selecterror1").val();     var selecterror2=$("#selecterror2").val();     var selecterror3=$("#selecterror3").val();     //var fimage=$("#fimage").val();     //alert($("#selecterror2").val().length); var datastring; var err; err=(txttitle!='' && txtcategoryname!='' &&  $("#selecterror1").val()!='0' &&  $("#selecterror2").val()!='0' &&  $("#selecterror3").val()!='0')?'0':'1'; // var datastring1="txttitle="+txttitle+"& description="+txtcategoryname+"& catname="+selecterror1+"& tags="+selecterror2; //datastring1="txttitle="+txttitle+"& description="+txtcategoryname+"& catname="+selecterror1+"& tags="+selecterror2+"& subcat="+selecterror3; //  alert(datastring1);      if(err=='0')     {     datastring="txttitle="+txttitle+"& description="+txtcategoryname+"& catname="+selecterror1+"& tags="+selecterror2+"& subcat="+selecterror3;     //alert(datastring);                 $.ajax({                                type: "post",                                url: "aadddescription.php",                                data: datastring,                               cache: true,                               beforesend: function(){ $("#adddesc").val('adding des.....');},             success: function(html){       //$("#txtcategoryname").val('');      tinymce.get('txtcategoryname').setcontent('');      $("#txttitle").val('');       //$("#selecterror1").get(0).selectedindex = 0;         //$("#error").removeclass("alert alert-error");     $("#error").addclass("alert alert-success");  $("#error").html("<span style='color:#cc0000'>success:</span> description added successfully. ").fadein().delay(3000).fadeout();              }             }); 

html form script

                        <form class="form-horizontal" method="post" action="" enctype="multipart/form-data"  autocomplete="off">                             <fieldset>                                <div class="control-group">                                 <label class="control-label" for="selecterror">select cateogry</label>                                 <div class="controls">                                                     <?php $result=mysqli_query($db,"select * categories "); //$count=mysqli_num_rows($result); $op="<option value='0'>select category</option>"; while($row=mysqli_fetch_array($result,mysqli_assoc)) { $op.="<option value='".$row['id']."'>".$row['title']."</option>"; } ?>                                   <select id="selecterror1" >                                     <?php echo $op; ?>                                   </select>                                 </div>                               </div>                <div class="control-group">                                 <label class="control-label" for="selecterror">select sub cateogry</label>                                 <div class="controls">                                    <select id="selecterror3">                                 <option selected="selected" value="0">--select sub--</option>                                   </select>                                 </div>                               </div>                                                           <div class="control-group">                                            <label class="control-label" for="focusedinput">enter title:: </label>     <div class="controls">                                           <input class="form-control"  type="text" id="txttitle" name="txttitle" value=""  placeholder="enter title"><span id="user-availability-status"></span> <img src="loadericon.gif" id="loadericon" style="display:none;width:20px;height:20px;" />                                        </div></div>                                             <div class="control-group">       <textarea rows="10" cols="20" name="content" style="width:100%; height:150px" id="txtcategoryname"></textarea>                                                                              </div>                                         <div class="control-group">                                 <label class="control-label" for="selecterror1">tags(select press ctrl)</label>                                 <div class="controls">                                     <?php $result=mysqli_query($db,"select * tags "); //$count=mysqli_num_rows($result); $op1=''; while($row=mysqli_fetch_array($result,mysqli_assoc)) { $op1.="<option value='".$row['title']."'>".$row['title']."</option>"; } ?>                                   <select id="selecterror2" multiple >                                     <?php //echo $op1; ?>                                   </select>                                 </div>                               </div>                                        <div class="form-actions">                                  <button type="submit" class="btn btn-primary" id="adddesc">save changes</button>                                 <button class="btn">cancel</button>                               </div>                             </fieldset>                         </form> 

aadddescription.php

<?php include("common/db.php"); session_start(); if(isset($_post['description']) && isset($_post['txttitle'])) { // username , password sent form $description=$_post['description'];  $txttitle=mysqli_real_escape_string($db,$_post['txttitle']);  $catname=mysqli_real_escape_string($db,$_post['catname']);  $subcat=mysqli_real_escape_string($db,$_post['subcat']);  $tags=mysqli_real_escape_string($db,$_post['tags']); //$fimage=$_files['fimage']['name'] ; $cby=$_session['login_user'];  //$result=mysqli_query($db,"select * categories title='$categoryname'"); //$count=mysqli_num_rows($result); //$target_dir = "uploads/"; //$target_file = $target_dir.$_files['fimage']['name']; //move_uploaded_file($_files['fimage']['tmp_name'],$target_file);   //$row=mysqli_fetch_array($result,mysqli_assoc); // if result matched $myusername , $mypassword, table row must 1 row /*if($count>0) { echo "0"; } else { mysqli_query($db,"insert  categories(title) values('".$categoryname."')"); echo "1"; }*/ //date_default_timezone_set('asia/delhi');  mysqli_query($db,"insert  description(title,description,cat_id,tags_id,created,modified,createdby,modifiedby,subcat_id) values('".$txttitle."','".$description."','".$catname."','".$tags."','".date("y-m-d h:i:s")."','".date("y-m-d h:i:s")."','".$cby."','".$cby."','".$subcat."')"); $cid=mysqli_insert_id($db); $cresult=mysqli_query($db,"select * counter cont_id='$cid'"); $ccount=mysqli_num_rows($cresult);  if($ccount==0) { mysqli_query($db,"insert  counter(cont_id) values(".$cid.")"); } echo "1"; } ?> 

please me thing wrong in code?...even changed cache false getting same problem. if type 1000/less or more lines data, taking limited data. please me. in advance

i'd willing bet text has characters in interfering url "&", "?", "/", "=", etc.

you should encode text encodeuricomponent() this:

var txtcategoryname=encodeuricomponent(tinymce.get('txtcategoryname').getcontent()); var txttitle=encodeuricomponent($('#txttitle').val()); var selecterror1=encodeuricomponent($("#selecterror1").val()); var selecterror2=encodeuricomponent($("#selecterror2").val()); var selecterror3=encodeuricomponent($("#selecterror3").val()); 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -