Android Question php strange behavour

jchal

Active Member
Licensed User
Longtime User
for some reason my php script started bechaving strange this morning,
it jumbs records !!!!
how is it possible this to happen?
the record table is
1
2
3
4
5
6
7
8
9
10
and the out put i get in web brouser is
1
3
5
7
9
it is the half
my question as i neve tach the script since i uploaded no the server how is it possile to stop working?
the php code is the following
B4X:
<?php

//include "include/DB_Connect.php";
$con = new mysqli("localhost", "user", "test", "testdb");
  
    mysqli_set_charset($con, "utf8");
    # check connection
    if ($con->connect_errno) {
        echo json_encode("MySQL error no ");
        exit();
    }

$query = "SELECT * FROM mytab";
$sql = mysqli_query($con, $query);
$json_response = array();

while ($row = mysqli_fetch_array($sql)) {
    $row_array['id'] = $row['b_id'];
    $row_array['name'] = $row['name'];
    $row_array['url'] = $row['path'];
    array_push($json_response, $row_array);
}
echo json_encode($json_response);
// now show the json tring

?>
 

DonManfred

Expert
Licensed User
Longtime User
Post the json too please which you get from this php returned
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
the loop is not required, just use

B4X:
echo json_encode($sql);

and make your field selection in the query.
 
Upvote 0
Top