我陷入了这个愚蠢的问题。这段代码应该显示'miejscowosci'表中的一行,但是看起来它什么也不返回,尽管查询在myadmin上正常工作。
$this->db = new mysqli(SRV, USR, PASS, DB_NAME);
if (mysqli_connect_errno())
{
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$stmt = $this->db->prepare("SELECT reg FROM miejscowosci WHERE nazwa = ?");
$stmt->bind_param("s", $city);
$stmt->execute();
if($stmt->store_result())
{
echo $stmt->num_rows; //this echoes 0
}
$stmt->bind_result($this->region);
while($stmt->fetch())
{
echo $this->region; //this echoes nothing
}
不带WHERE子句的查询给出正确的输出。
好了,看来这个问题是编码和我加入解决了它$mysqli->set_charset("utf8");
或取消注释collation_server=utf8_unicode_ci
,并character_set_server=utf8
在php.ini中。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句