I have a code in php that takes information from two different columns of the same table in a local database, but the code does not seem to work when one of the columns has information with space, for example: "Romeo Juliet" but is written: "Romeu_julieta" the code works, can anyone help me? Here is the code:
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "teste";
$conn = new mysqli ($servername,$username,$password,$dbname);
if ($conn->connect_error){
die("Connection failed: " . $conn->connect_error);
}
$sql1 = "SELECT abbreviation,image FROM je";
$result1 = $conn->query($sql1);
$i=0;
$resultado = array(array(),array());
while ($row = $result1->fetch_assoc()){
$resultado[$i]["imagem"] = $row["image"];
$resultado[$i]["abrevia"] = $row["abbreviation"];
$i++;
}
echo json_encode($resultado);
?>