【发布时间】:2018-09-03 07:13:09
【问题描述】:
我在 PHP 中有这个功能:
public function getData($data) {
echo $data; //param still right for example: Schärding
$result = mysqli_query($this->conn, "CALL sp_kampagne_findcurrent ('".$data."')") or die(mysqli_error($this->conn));
@mysqli_next_result($this->conn);
return $result;
}
如您所见,我将参数 $data 传递给我的 SP,然后返回结果。
这里的问题是,如果我传递单词 without Umlauts (ä,ö,ü),它会完美运行,但如果我使用像“Schärding”这样的词,它会返回零数据,即使有数据存储在 MySQL 中。
奇怪的是,如果我在PHPmyAdmin 中直接调用我的 SP 它与“Schärding”这个词一起工作。所以错误必须在PHP客户端。
如果您需要更多信息,请直接说出来。我会尝试添加更多信息。
【问题讨论】:
-
你的数据库是用utf-8编码的?
-
@Alberto its utf8_general_ci
-
使用
stored procedures,而不是使用嵌入式变量打开代码进行sql注入 -
@RamRaider 你是什么意思?更多细节请