I'm retrieving data from a SQL database with these lines of code
$username = $_POST['username'];
$selector = "SELECT * FROM client_table WHERE SalesmanID ='" . $username . "';";
$result = mysqli_query($con,$selector);
while($row = mysqli_fetch_array($result)) {
echo $row['ID'] . "/" . $row['Name'] . "/" . $row['Address'] . "/" . $row['Zip Code'] . "/" . $row['SalesmanID'];
echo "\\r\\n";
}
?>
On the Java side I do
while ((bufferedStrChunk = bufferedReader.readLine()) != null) {
stringBuilder.append(bufferedStrChunk);
}
String queryResult = stringBuilder.toString();
and the problem is that when I do
String[] results=queryResult.split("\n");
the string is not split. Could someone please help?
In PHP code you used escape to
\
by\\
that makes string appended with\
-char followed byn
-character AND in Java code you are splitting by new line char\n
. This can be cause of problem.Try it with escaped
\
:That should work.