I need to know If php, mysql or even my script has a limit of values or memory, or something that doesn't show me all the values of my database table.
Here is my script:
<?php
define('HOST','localhost');
define('USER','root');
define('PASS','');
define('DB','');
$con = mysqli_connect(HOST,USER,PASS,DB);
$sql = "SELECT id_team,name FROM teams ORDER BY id_team LIMIT 50;";
$res = mysqli_query($con,$sql);
$result = array();
while($row = mysqli_fetch_array($res)){
array_push($result,
array('id_team'=>$row[0],'name'=>$row[1]));
}
echo json_encode(array("result"=>$result));
mysqli_close($con);
?>
If I run this script with the LIMIT 50 condition, it works, but when I change the limit to 70 or more It doesn't work anymore and doesn't print me anything. I don't know if there is like a limit of memory or values or something. Can someone help me please?
This is my output when I use Limite 5 (for example):
{"result":[{"id_team":"3","name":"Tonkas"},{"id_team":"4","name":"Combis"},{"id_team":"5","name":"Looney Tunes"},{"id_team":"6","name":"Bullets"},{"id_team":"7","name":"Valkiry"}]}
I use a counter inside the loop and It always return me the number of the LIMIT I give in the condition, If I give LIMIT 100, the counter prints me 100, but I don't get anything from the array. PHP Version 5.6.29 & JSON version 1.2.1 - Hosted in 1and1
SOLVED It was the codification (charset) when the loop found a invalid character (in this case letter 'ñ') it just break and didn't continue filling the array, just set the charset and worked:
mysqli_set_charset($con,'utf8');