This is my code to output a row from table
if (empty($_GET['artist']))
exit;
$q = $_GET["artist"];
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT artistName FROM artists WHERE (artistName LIKE '".$q."%')";
$sth = mysqli_query($conn, $sql);
$json = mysqli_fetch_all ($sth, MYSQLI_ASSOC);
echo json_encode($json);
$conn->close();
Now the table contains columns of various sizes, if I do this
$sql = "SELECT * FROM artists WHERE (artistName LIKE '".$q."%')";
Network Inspect in Chrome says failed to load response data
but if I do this
$sql = "SELECT artistName, ... FROM artists WHERE (artistName LIKE '".$q."%')";
It outputs the data just fine.
Please tell me what am I doing wrong.
I'm working on Apache server, just FYI.