2
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);

}

Instead of having a varchar on result I get a number

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

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

)

The result should contain string or varchar. I don't know why it returns a 5 value. Please help.

Disha V.
  • 1,834
  • 1
  • 13
  • 21

1 Answers1

1

Remove ' from Iloco column name.

Use this.

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

On User Demand.

$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'];
Nana Partykar
  • 10,556
  • 10
  • 48
  • 77