dongxuan1660 2014-09-07 10:58 采纳率: 100%
浏览 85
已采纳

处理单引号和双引号php和ajax

hello all i am having a project where a user can write any comment on any post currently everything is going very good i mean that the user can post and comment successfully but when the user comments any line which contains any single or double quote the whole text is just skipped nothing is displayed . like the text i'll call you is not displayed but i will call you is displayed i know i need to use addslashes but i don't know how to use it. i tried to addslashe after the post variable and then send it to database bit nothing happens

here is my form and code

JS

function formsubmitionbyajax(obj){
        $.ajax({ type: 'post',
        url: 'home_formhandler1.php',
        data: $("#postform").serialize(),
        success: function(){
        $("#LOADreftraed").load("Mypage.php #LOADreftraed");
        $("#postform")[0].reset();
}   } );    return false;   }

PHP action page

 $views=$_POST['views'];
 $comment=$_POST['comment'];
 $onid=$_POST['onid'];
 $onemail=$_POST['onemail'];

  $insertposts=mysql_query("insert into `fk_views` (`views`,`session_id`,`email`,`Date`) 
  values    ('$views','$sid','$email','$time')");
   exit;

i have many forms like this and is there any way to addslash to all the post variables and then send them to BD please help me .

  • 写回答

1条回答 默认 最新

  • dongluan2612 2014-09-07 11:13
    关注

    use it like

    $views=mysql_real_escape_string($_POST['views']);
    

    for more see documentation

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥15 复杂网络,变滞后传递熵,FDA
  • ¥20 csv格式数据集预处理及模型选择
  • ¥15 部分网页页面无法显示!
  • ¥15 怎样解决power bi 中设置管理聚合,详细信息表和详细信息列显示灰色,而不能选择相应的内容呢?
  • ¥15 QTOF MSE数据分析
  • ¥15 平板录音机录音问题解决