Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 向MySQL插入特殊字符_Php_Mysql - Fatal编程技术网

Php 向MySQL插入特殊字符

Php 向MySQL插入特殊字符,php,mysql,Php,Mysql,您好,我正在尝试将特殊字符插入MySQL,因为我无法使用它们 这就是我到目前为止得到的 mysql_query("UPDATE profiles SET .mysql_real_escape_string playground='$_POST[playground]' WHERE username='$_SESSION[membersusername]'"); 文本形式为 <form method="POST" action="playground.php?action=

您好,我正在尝试将特殊字符插入MySQL,因为我无法使用它们

这就是我到目前为止得到的

   mysql_query("UPDATE profiles SET .mysql_real_escape_string playground='$_POST[playground]' WHERE
     username='$_SESSION[membersusername]'");
文本形式为

<form method="POST" action="playground.php?action=edit">


            <table width="100%" border="0" align="center">
  <tr>
    <td width="341">Playground<br><textarea name="playground" id="maxLength" rows="5" cols="50"><? echo $playground ?></textarea></td>
  </tr>
  <tr>
    <td><input type="submit" name="submit" value="Update" /></td>
  </tr>
          </table>

  </form>   

操场
希望有人能帮上忙。

试试这个

 $playground = mysql_real_escape_string($_POST[playground]) ;
 mysql_query("UPDATE profiles SET  playground='$playground' 
              WHERE username='".$_SESSION['membersusername']."' ");
换线

 <td width="341">Playground<br><textarea name="playground" id="maxLength" rows="5" cols="50"><? echo $playground ?></textarea></td>
操场

操场

您的查询中有语法错误,请按如下所示进行更改

mysql_query("UPDATE profiles SET playground='".mysql_real_escape_string($_POST['playground'])."' WHERE   username='".$_SESSION['membersusername']."'");

作为旁注,我会告诉您将预先准备好的语句与
PDO
mysqli
一起使用,您的代码实际上非常容易受到
mysql注入的影响,

查询不正确,应该正确

mysql_query("UPDATE profiles 
SET  playground='".mysql_real_escape_string($_POST[playground])."' 
WHERE
username='".$_SESSION[membersusername]."'");

您应该如何停止使用mysql_*函数,因为它们已被弃用,并开始使用mysqli_*函数或PDO with prepare语句。

这就是为什么您使用prepare语句,但更重要的是语法错误。
UPDATE TABLE SET COLUMN…
这很有效,谢谢大家!我知道我正在尝试在服务器上获取iMySQL。
mysql_query("UPDATE profiles 
SET  playground='".mysql_real_escape_string($_POST[playground])."' 
WHERE
username='".$_SESSION[membersusername]."'");