As3&;PHP URL编码问题!
我陷入了一个愚蠢的编码问题 我的问题是,我所有的重音字符都显示为奇怪的iso字符 示例:显示了%E9 我向我的php文件发送一个字符串:As3&;PHP URL编码问题!,php,mysql,flash,actionscript-3,Php,Mysql,Flash,Actionscript 3,我陷入了一个愚蠢的编码问题 我的问题是,我所有的重音字符都显示为奇怪的iso字符 示例:显示了%E9 我向我的php文件发送一个字符串: XMLLoader.load(new URLRequest(online+"/query.php?Query=" + q)); XMLLoader.addEventListener(Event.COMPLETE,XMLLoaded); 当我追踪q时,我得到: “插入hello_world(消息) 价值观(‘a’);” 好的查询 我的php文件如下所示: &l
XMLLoader.load(new URLRequest(online+"/query.php?Query=" + q));
XMLLoader.addEventListener(Event.COMPLETE,XMLLoaded);
当我追踪q时,我得到:
“插入hello_world(消息)
价值观(‘a’);”
好的查询
我的php文件如下所示:
<?php
include("conection.php");//Conectiong to database
$Q = $_GET['Query'];
$query = $Q;
$resultID = mysql_query($query) or die("Could not execute or probably SQL statement malformed (error): ". mysql_error());
$xml_output = "<?xml version=\"1.0\"?>\n"; // XML header
$xml_output .= "<answers>\n";
$xml_output .= "<lastID id=".'"'.mysql_insert_id().'"'." />\n";
$xml_output .= "<query string=".'"'.$query.'"'." />\n";
$xml_output .= "</answers>";
echo $xml_output;//Output the XML
?>
$Q = mysql_real_escape_string($_POST['Query']);
$query = "INSERT INTO hello_world (message) values ('".$Q."')";
当我将XML返回flash时,$查询如下所示:
<?php
include("conection.php");//Conectiong to database
$Q = $_GET['Query'];
$query = $Q;
$resultID = mysql_query($query) or die("Could not execute or probably SQL statement malformed (error): ". mysql_error());
$xml_output = "<?xml version=\"1.0\"?>\n"; // XML header
$xml_output .= "<answers>\n";
$xml_output .= "<lastID id=".'"'.mysql_insert_id().'"'." />\n";
$xml_output .= "<query string=".'"'.$query.'"'." />\n";
$xml_output .= "</answers>";
echo $xml_output;//Output the XML
?>
$Q = mysql_real_escape_string($_POST['Query']);
$query = "INSERT INTO hello_world (message) values ('".$Q."')";
“插入hello_world(消息)
值(“%E9%E0a%E0”)
然后这些值显示在我的数据库中,这很烦人
任何帮助都将不胜感激!干杯
Jk_flash可能正在请求带有编码参数/querystring的url,因此在php中使用urlencode对其进行解码 i、 e
$Q=urldecode($_GET['Query']) flash可能正在请求带有编码参数/querystring的url,因此在php中使用urlencode对其进行解码 i、 e $Q=urldecode($_GET['Query']) 将完成这项工作 另一方面,像这样发送查询是非常糟糕的做法。发送必要的数据,对其进行过滤,然后构造查询,除非您正在构建phpMyAdmin的克隆。将完成此工作
另一方面,像这样发送查询是非常糟糕的做法。发送必要的数据,过滤它,然后构造查询,除非您正在构建phpMyAdmin的克隆。我的问题现在解决了 正如上面所写的那样,使用GET发送查询确实是个坏主意 当我使用以下方式从Flash发送数据时:
XMLLoader.load(new URLRequest(online+"/query.php?Query=" + q));
URL是经过编码的,即使使用urldecode,我的数据库中也有一个空白条目
所以多亏了andr和raz-l,我改变了将数据发送到php文件的方式
在flash中,我使用URL变量,在PHP中,我构建查询:
variables = new URLVariables();
variables.Query = "éàûï ceci est un test...";
request.method = URLRequestMethod.POST;
request.data = variables;
XMLLoader.load(request);
我的php文件如下所示:
<?php
include("conection.php");//Conectiong to database
$Q = $_GET['Query'];
$query = $Q;
$resultID = mysql_query($query) or die("Could not execute or probably SQL statement malformed (error): ". mysql_error());
$xml_output = "<?xml version=\"1.0\"?>\n"; // XML header
$xml_output .= "<answers>\n";
$xml_output .= "<lastID id=".'"'.mysql_insert_id().'"'." />\n";
$xml_output .= "<query string=".'"'.$query.'"'." />\n";
$xml_output .= "</answers>";
echo $xml_output;//Output the XML
?>
$Q = mysql_real_escape_string($_POST['Query']);
$query = "INSERT INTO hello_world (message) values ('".$Q."')";
我的问题现在解决了 正如上面所写的那样,使用GET发送查询确实是个坏主意 当我使用以下方式从Flash发送数据时:
XMLLoader.load(new URLRequest(online+"/query.php?Query=" + q));
URL是经过编码的,即使使用urldecode,我的数据库中也有一个空白条目
所以多亏了andr和raz-l,我改变了将数据发送到php文件的方式
在flash中,我使用URL变量,在PHP中,我构建查询:
variables = new URLVariables();
variables.Query = "éàûï ceci est un test...";
request.method = URLRequestMethod.POST;
request.data = variables;
XMLLoader.load(request);
我的php文件如下所示:
<?php
include("conection.php");//Conectiong to database
$Q = $_GET['Query'];
$query = $Q;
$resultID = mysql_query($query) or die("Could not execute or probably SQL statement malformed (error): ". mysql_error());
$xml_output = "<?xml version=\"1.0\"?>\n"; // XML header
$xml_output .= "<answers>\n";
$xml_output .= "<lastID id=".'"'.mysql_insert_id().'"'." />\n";
$xml_output .= "<query string=".'"'.$query.'"'." />\n";
$xml_output .= "</answers>";
echo $xml_output;//Output the XML
?>
$Q = mysql_real_escape_string($_POST['Query']);
$query = "INSERT INTO hello_world (message) values ('".$Q."')";
Jk_$q=mysql_real_escape_字符串(urldecode($\u GET['Query']) $q=mysql\u real\u escape\u字符串(urldecode($\u GET['Query']) 这样做的问题是,我的数据库字段消息是空的!数据已发送到数据库,但字段为空…可能是您的数据库有问题。。。它接受UTF8字符吗?消息长度是否在其范围内?这样做的问题是,我的数据库字段消息为空!数据已发送到数据库,但字段为空…可能是您的数据库有问题。。。它接受UTF8字符吗?消息长度是否在其范围内?在我的例子中,这比较容易,因为我从一个as3类处理同一php文件的不同查询。但我可以理解为什么这是一种非常糟糕的做法。在我的例子中,这比较容易,因为我从一个as3类处理同一php文件的不同查询。但我可以理解为什么这是一种非常糟糕的做法。
$Q=mysql_real_escape_字符串($_POST['Query'])代码>。“解决了”!。是啊,最好是这样!谢谢上校。$Q=mysql\u real\u escape\u字符串($\u POST['Query'])代码>。“解决了”!。是啊,最好是这样!谢谢你,上校。