【发布时间】:2015-03-21 01:50:45
【问题描述】:
我的 SQL 数据库和我的 Android 应用程序之间有一个 webServer。在数据库上我想放一个带问号的句子,但是当网络服务器捕获查询时,回显为空。只有当我在短语中使用问号、点或逗号时才会发生这种情况。 网络服务器的代码是:
<?php
$hostname_localhost ="*****";
$database_localhost ="*****";
$username_localhost ="*****";
$password_localhost ="*****";
$localhost = mysql_connect($hostname_localhost,$username_localhost,$password_localhost)
or
trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database_localhost, $localhost);
$resultado = mysql_query('SELECT pregunta,respuesta,intentos,frase FROM Frases');
if (!$resultado) {
die('Consulta no válida: ' . mysql_error());
}
while ($fila = mysql_fetch_assoc($resultado)) {
$pregunta = $fila['pregunta'];
$respuesta = $fila['respuesta'];
$intentos = $fila['intentos'];
$frase = $fila['frase'];
}
mysql_close($localhost);
$data = array('pregunta' => $pregunta, 'respuesta' => $respuesta, 'intentos' => $intentos, 'frase' => $frase);
print (json_encode($data));
?>
【问题讨论】:
-
我认为翻译中有些东西丢失了。 “审讯”是什么意思?
-
他的意思可能是问号,我不懂西班牙语,但它们在葡萄牙语中被称为“Interrogação”
-
是的,问号对不起
-
我的猜测是
json_encode会中断,但我真的没有看到任何会破坏它的东西。你能知道null是怎么产生的吗? -
null 是当我的查询中的短语有一些问号或点或任何特殊字符时
标签: php android mysql sql json