mysqli_query返回number而不是varchar

时间:2015-12-16 12:58:22

标签: php mysqli

require 'connection.php';

if(isset($_POST['input'])){
    $input = mysqli_real_escape_string($conn ,$_POST['input']);

    $query = mysqli_query($conn,"SELECT 'Iloco' FROM ylokaknow.words WHERE English='$input'") or die(mysqli_error($conn));

print_r($query);

}

不是在结果上有varchar而是得到一个数字

mysqli_result Object
(
    [current_field] => 0
    [field_count] => 1
    [lengths] => Array
      (
        [0]=> 5
      )

    [num_rows] => 1
    [type] => 0

)

结果应包含字符串或varchar。我不知道为什么它返回5值。请帮忙。

1 个答案:

答案 0 :(得分:1)

'列名称中删除Iloco

使用此功能。

$query = mysqli_query($conn,"SELECT Iloco FROM ylokaknow.words WHERE English='$input'") or die(mysqli_error($conn));

用户需求。

$query = mysqli_query($conn,"SELECT Iloco FROM words WHERE English='$input'") or die(mysqli_error($conn)); 
$row = mysqli_fetch_array($query, MYSQLI_ASSOC); 
echo $Iloco = $row['Iloco'];