if(isset($_POST['job']) && $_POST['job']=="edit"){
 //$MySql_update=addslashes($MySql_update);
    $MySql_update="update hotel_activities_2 set hotel_id='".$_POST['hotel_id']."',start_date='".$_POST['start_date']."',end_date='".$_POST['end_date']."',content='".$_POST['content']."',source='".$_POST['source']."',s_type='".$_POST['s_type']."' where h_id=".$_POST['hid'];
   
    $result=mysql_query($MySql_update); 

解决方案 »

  1.   

    $MySql_update=mysql_real_escape_string("update hotel_activities_2 set hotel_id='".$_POST['hotel_id']."',start_date='".$_POST['start_date']."',end_date='".$_POST['end_date']."',content='".$_POST['content']."',source='".$_POST['source']."',s_type='".$_POST['s_type']."' where h_id=".$_POST['hid']);
    $result=mysql_query($MySql_update);
      

  2.   

    我晕这个函数是给变量用的 
    给$_POST['hotel_id']这些变量用的 
      

  3.   

    可这么写$MySql_update="update hotel_activities_2 set hotel_id='".addslashes($_POST['hotel_id'])."',start_date='".addslashes($_POST['start_date'])."',end_date='".addslashes($_POST['end_date'])."',content='".addslashes($_POST['content'])."',source='".addslashes($_POST['source'])."',s_type='".addslashes($_POST['s_type'])."' where h_id=".$_POST['hid'];
    太麻烦了,还有没有更方便的
      

  4.   

    就这么着吧,要不连sql语句中的'和"受到影响了
      

  5.   

    mysql_real_escape_string
    转义下列
    \x00
    \n
    \r
    \
    '
    "
    \x1a
    你输出你的sql语句看下为什么不行
    用addslashes也不用每个都加 直接一个循环就可以搞定
      

  6.   

    你这是直接将传入的数据用于 SQL 指令,比较危险。
    如果你能确认不存在 SQL 注入的危险,那么做起来还是很简单的if( ! get_magic_quotes_gpc() ) { //检查是否启用了自动外部数据转义
      set_magic_quotes_runtime(1); //若没有,则启用传入数据库数据自动转义
    }
    $MySql_update="update ...... ";